We created a "ngram index" and search works fine. However, returning results are not what we want to have.
In case we do have the following words in our index:
this
test
tests
the index
and I search for "th" I´d like to get a result list
this
the text
Means the beginning of the matches (this is for autocomplete). I tried it with "highlight" but I always get more parts of the document (not only the words starting with "th").
How can I tell ElasticSearch to get a search result which contains the "autocomplete" words?
Take a look at the edge_ngram tokenizer or the edgeNGram token filter, rather than the regular ngram tokenizer/token filter. These will only generate ngrams from the start of the words.
If you're doing autocomplete, have you considered using the Completion Suggester instead?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.