Substring search


(be.the.water) #1

Does Elasticsearch support (or what are the options for) substring
search?

Example "ball" or "bal" in basketball?

Thanks.


(Thomas Peuss) #2

Hi Anonymous!

Am Sonntag, 25. März 2012 22:36:09 UTC+2 schrieb be.the.water:

Does Elasticsearch support (or what are the options for) substring
search?

Example "ball" or "bal" in basketball?

You have two options:

  1. Use ngrams through the ngram token filter:
    http://www.elasticsearch.org/guide/reference/index-modules/analysis/ngram-tokenfilter.html.
    See Wikipedia for details: http://en.wikipedia.org/wiki/N-gram
  2. Use the compound token filter
    http://www.elasticsearch.org/guide/reference/index-modules/analysis/compound-word-tokenfilter.html
    (which I have contributed to Lucene btw.)

The ngrams are useful if you cannot provide a dictionary because you don't
know what type of documents you have to index. The downside is that they
use a lot of space in your indices. So you need to be careful here.

CU

Thomas


(system) #3