elasticsearchelasticsearch-mapping

What's the difference between Search-as-you-type datatype and Edge NGram Tokenizer?


Can't understand the difference between setting a Search-as-you-type datatype to a field, setting an Edge NGram Tokenizer in analyzer, and adding an index_prefixes parameter. It seems to me that they do the same job after all.

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-as-you-type.html https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-edgengram-tokenizer.html https://www.elastic.co/guide/en/elasticsearch/reference/current/index-prefixes.html


Solution

  • edge_ngram is a tokenizer, which means it kicks in at indexing time to tokenize your input data. There is also a edge_ngram token filter. Both are similar but work at different levels.

    search_as_you_type is a field type which contains a few sub-fields, one of which is called _index_prefix and which leverages the edge_ngram tokenizer.

    So basically, what you see in the edge_ngram tokenizer documentation has actually been leveraged when they decided to add the new search_as_you_type field type.