Query Results for "ngram" search


#1

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?

Thank you.


(Abdon Pijpelink) #2

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?


#3

Hello, thank you for this fast response. This works for us (the edge_ngram tokenizer).


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.