Created
December 4, 2012 13:30
-
-
Save martijnvg/4203869 to your computer and use it in GitHub Desktop.
testing highlighting fragment_size option.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XDELETE 'localhost:9200' | |
curl -XPUT 'localhost:9200/nyt' -d '{ | |
"settings": { | |
"analysis": { | |
"filter": { | |
"token_ngrams": { | |
"side": "front", | |
"max_gram": 20, | |
"min_gram": 2, | |
"type": "edgeNGram" | |
} | |
}, | |
"analyzer": { | |
"analyzer_lower_substring": { | |
"filter": [ | |
"standard", | |
"lowercase", | |
"asciifolding", | |
"stop" | |
], | |
"type": "custom", | |
"tokenizer": "standard" | |
}, | |
"analyzer_lower_ngram": { | |
"filter": [ | |
"standard", | |
"lowercase", | |
"asciifolding", | |
"stop", | |
"token_ngrams" | |
], | |
"type": "custom", | |
"tokenizer": "standard" | |
} | |
} | |
}, | |
"index": { | |
"query": { | |
"default_field": "body" | |
}, | |
"store": { | |
"compress": { | |
"stored": "true", | |
"tv": "true" | |
} | |
}, | |
"number_of_shards": 5, | |
"number_of_replicas": 1 | |
} | |
}, | |
"mappings": { | |
"_default_": { | |
"_source": { | |
"enabled": true | |
}, | |
"properties": { | |
"body": { | |
"type": "multi_field", | |
"fields": { | |
"body": { | |
"type": "string", | |
"store": "yes", | |
"analyzer": "analyzer_lower_substring" | |
}, | |
"search": { | |
"type": "string", | |
"store": "no", | |
"search_analyzer": "analyzer_lower_substring", | |
"index_analyzer": "analyzer_lower_ngram" | |
} | |
} | |
}, | |
"byline": { | |
"type": "multi_field", | |
"fields": { | |
"byline": { | |
"type": "string", | |
"store": "no", | |
"analyzer": "analyzer_lower_substring" | |
} | |
} | |
}, | |
"creative_works": { | |
"type": "multi_field", | |
"fields": { | |
"creative_works": { | |
"type": "string", | |
"store": "no", | |
"index": "not_analyzed" | |
}, | |
"contains": { | |
"type": "string", | |
"store": "no", | |
"analyzer": "analyzer_lower_substring" | |
} | |
} | |
}, | |
"document_source": { | |
"type": "string", | |
"store": "yes", | |
"index": "not_analyzed" | |
}, | |
"document_type": { | |
"type": "string", | |
"store": "yes", | |
"index": "not_analyzed" | |
}, | |
"expiration_date": { | |
"type": "date", | |
"store": "no", | |
"index": "not_analyzed" | |
}, | |
"glocations": { | |
"type": "multi_field", | |
"fields": { | |
"glocations": { | |
"type": "string", | |
"store": "no", | |
"index": "not_analyzed" | |
}, | |
"contains": { | |
"type": "string", | |
"store": "no", | |
"analyzer": "analyzer_lower_substring" | |
} | |
} | |
}, | |
"headline": { | |
"type": "multi_field", | |
"fields": { | |
"headline": { | |
"type": "string", | |
"store": "yes", | |
"analyzer": "analyzer_lower_substring" | |
}, | |
"search": { | |
"type": "string", | |
"store": "no", | |
"search_analyzer": "analyzer_lower_substring", | |
"index_analyzer": "analyzer_lower_ngram" | |
} | |
} | |
}, | |
"kicker": { | |
"type": "multi_field", | |
"fields": { | |
"kicker": { | |
"type": "string", | |
"store": "no", | |
"index": "not_analyzed" | |
}, | |
"contains": { | |
"type": "string", | |
"store": "no", | |
"analyzer": "analyzer_lower_substring" | |
} | |
} | |
}, | |
"knews_url": { | |
"type": "string", | |
"store": "no", | |
"index": "not_analyzed" | |
}, | |
"lead_paragraph": { | |
"type": "string", | |
"store": "no", | |
"index": "no" | |
}, | |
"news_desk": { | |
"type": "multi_field", | |
"fields": { | |
"news_desk": { | |
"type": "string", | |
"store": "no", | |
"index": "not_analyzed" | |
}, | |
"contains": { | |
"type": "string", | |
"store": "no", | |
"analyzer": "analyzer_lower_substring" | |
} | |
} | |
}, | |
"nytddes": { | |
"type": "string", | |
"store": "no", | |
"analyzer": "analyzer_lower_substring" | |
}, | |
"organizations": { | |
"type": "multi_field", | |
"fields": { | |
"organizations": { | |
"type": "string", | |
"store": "no", | |
"index": "not_analyzed" | |
}, | |
"contains": { | |
"type": "string", | |
"store": "no", | |
"analyzer": "analyzer_lower_substring" | |
} | |
} | |
}, | |
"persons": { | |
"type": "multi_field", | |
"fields": { | |
"persons": { | |
"type": "string", | |
"store": "no", | |
"index": "not_analyzed" | |
}, | |
"contains": { | |
"type": "string", | |
"store": "no", | |
"analyzer": "analyzer_lower_substring" | |
} | |
} | |
}, | |
"pub_date": { | |
"type": "date", | |
"store": "no", | |
"index": "not_analyzed" | |
}, | |
"pub_year": { | |
"type": "integer", | |
"store": "no", | |
"index": "not_analyzed" | |
}, | |
"secpg": { | |
"type": "string", | |
"store": "no", | |
"analyzer": "analyzer_lower_substring" | |
}, | |
"source": { | |
"type": "string", | |
"store": "no", | |
"analyzer": "analyzer_lower_substring" | |
}, | |
"subject": { | |
"type": "multi_field", | |
"fields": { | |
"subject": { | |
"type": "string", | |
"store": "no", | |
"index": "not_analyzed" | |
}, | |
"contains": { | |
"type": "string", | |
"store": "no", | |
"analyzer": "analyzer_lower_substring" | |
} | |
} | |
}, | |
"section_name": { | |
"type": "string", | |
"store": "no", | |
"index": "not_analyzed" | |
}, | |
"taxonomy_nodes": { | |
"type": "string", | |
"store": "no", | |
"index": "not_analyzed" | |
}, | |
"type_of_material": { | |
"type": "string", | |
"store": "no", | |
"index": "not_analyzed" | |
}, | |
"update": { | |
"type": "date", | |
"store": "no", | |
"index": "not_analyzed" | |
}, | |
"old_url": { | |
"type": "string", | |
"store": "no", | |
"index": "not_analyzed" | |
}, | |
"web_url": { | |
"type": "string", | |
"store": "yes", | |
"index": "not_analyzed" | |
} | |
} | |
} | |
} | |
}' | |
curl -XPUT 'localhost:9200/nyt/content/1' -d '{ | |
"headline" : "mitt romney", | |
"body" : "begin some text some text some text some text some text some text some text some text some text some text Some text some text some text some text some text some text some text mitt romney some textsome text some text some. text some text some text some textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome text some text end" | |
}' | |
curl -XGET 'localhost:9200/_refresh' | |
curl -XGET 'localhost:9200/nyt/_search?pretty' -d '{ | |
"fields":[ | |
"_id", | |
"document_type", | |
"document_source" | |
], | |
"highlight":{ | |
"pre_tags":[ | |
"<strong>" | |
], | |
"post_tags":[ | |
"<\/strong>" | |
], | |
"fields":{ | |
"body":{ | |
"fragment_size":200, | |
"number_of_fragments":1 | |
}, | |
"headline":{ | |
"fragment_size":200, | |
"number_of_fragments":1 | |
} | |
} | |
}, | |
"from":0, | |
"query":{ | |
"query_string":{ | |
"query":"\"mitt romney\"" | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment