I have been playing around with ElasticSearch for a new project of mine. I have set the default analyzers to use the ngram tokenfilter. This is my elasticsearch.yml file:
index:
analysis:
analyzer:
default_index:
tokenizer: standard
filter: [standard, stop, mynGram]
default_search:
tokenizer: standard
filter: [standard, stop]
filter:
mynGram:
type: nGram
min_gram: 1
max_gram: 10
I created a new index and added the following document to it:
$ curl -XPUT http://localhost:9200/test/newtype/3 -d '{"text": "one two three four five six"}'
{"ok":true,"_index":"test","_type":"newtype","_id":"3"}
However, when I search using the query text:hree
or text:ive
or any other partial terms, ElasticSearch does not return this document. It returns the document only when I search for the exact term (like text:two
).
I have also tried changing the config file such that default_search also uses the ngram token filter, but the result was the same. What am I doing wrong here and how do I correct it?