# Substring search

**URL:** <https://discuss.elastic.co/t/substring-search/7117>\
**Category:** Elasticsearch\
**Created:** [March 25, 2012, 8:36pm UTC](https://discuss.elastic.co/t/substring-search/7117 "2012-03-25T20:36:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![be\_the\_water](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/be_the_water/32/2944_2.png) [@be\_the\_water](https://discuss.elastic.co/u/be_the_water)\
**Post date:** [March 25, 2012, 8:36pm UTC](https://discuss.elastic.co/t/substring-search/7117/1 "2012-03-25T20:36:09Z")

</div>

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

Example "ball" or "bal" in basketball?

Thanks.

---

<div class="post-metadata">

**Author:** ![Thomas\_Peuss](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@Thomas\_Peuss](https://discuss.elastic.co/u/Thomas_Peuss)\
**Post date:** [March 26, 2012, 6:26am UTC](https://discuss.elastic.co/t/substring-search/7117/2 "2012-03-26T06:26:07Z")

</div>

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:  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/ngram-tokenfilter.html).  
See Wikipedia for details: [n-gram - Wikipedia](http://en.wikipedia.org/wiki/N-gram)
2. Use the compound token filter  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:34am UTC](https://discuss.elastic.co/t/substring-search/7117/3 "2017-07-06T03:34:51Z")

</div>


