Created
September 10, 2013 01:01
-
-
Save scottrice10/6503689 to your computer and use it in GitHub Desktop.
Here is a mapping using an ngram filter enabling Elasticsearch to search on word fragments, which is necessary for autocomplete. An alternative/addition to using an ngram filter (not shown here) would be to use a shingle filter, which additionally searches on phrase fragments.
This file contains hidden or 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 -XPUT 'localhost:9200/doctors_index' -d ' | |
| { | |
| "settings": { | |
| "analysis": { | |
| "analyzer": { | |
| "autocomplete": { | |
| "type": "custom", | |
| "tokenizer": "standard", | |
| "filter": ["standard", "lowercase", "kstem", "edgeNGram"] | |
| } | |
| }, | |
| "filter" : { | |
| "ngram" : { | |
| "type": "edgeNGram", | |
| "min_gram": 2, | |
| "max_gram": 15 | |
| } | |
| } | |
| } | |
| }, | |
| "mappings": { | |
| "doctors" : { | |
| "properties": { | |
| "first_name": { | |
| "type": "multi_field", | |
| "fields": { | |
| "first_name": { | |
| "type": "string" | |
| }, | |
| "post_title": { | |
| "type": "string", | |
| "analyzer": "post_title", | |
| "similarity": "BM25" | |
| }, | |
| "autocomplete": { | |
| "analyzer": "autocomplete", | |
| "type": "string" | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment