# Long Words Matching

**URL:** https://discuss.elastic.co/t/long-words-matching/7961
**Category:** Elasticsearch
**Created:** [June 4, 2012, 9:34am UTC](https://discuss.elastic.co/t/long-words-matching/7961 "2012-06-04T09:34:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Mats\_Stijlaart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mats_stijlaart/32/2868_2.png) [@Mats\_Stijlaart](https://discuss.elastic.co/u/Mats_Stijlaart)
#### Post date: [June 4, 2012, 9:34am UTC](https://discuss.elastic.co/t/long-words-matching/7961/1 "2012-06-04T09:34:35Z")

</div>

I'm creating a index that contains both small and long words (more then 18)  
characters.

Currently i am using a ngram token filter with a minimum of 1 and a maximum  
of 20.  
Words that have more then 20 characters will not match because they are not  
fully indexed.

It is possible to index those words 'untouched'. But then i still cannot  
get matches for substrings with a length between 20 and the full-word  
length.

I've considered to increase the ngram maximum to 50, but i think that will  
bring down the performance and theoretically does not solve the problem (i  
cannot think of any, but words may have more then 50 characters).

I'm looking for the 'best' solution to tackle this problem that keeps my  
performance intact and allows me to find any long word with any random  
substring.

Thanks.

---

<div class="post-metadata">

### Author: ![AEvar\_Arnfjord\_Bjarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aevar_arnfjord_bjarm/32/2746_2.png) [@AEvar\_Arnfjord\_Bjarm](https://discuss.elastic.co/u/AEvar_Arnfjord_Bjarm)
#### Post date: [June 4, 2012, 11:18am UTC](https://discuss.elastic.co/t/long-words-matching/7961/2 "2012-06-04T11:18:09Z")

</div>

I'm not sure how exactly the scoring ends up working out, but you  
don't need an nGram tokenizer of length N to match a word of length N,  
although your scoring might suffer slightly.

Let's say you split up "Stijlaart" with an ngram 2..3 tokenizer. Then  
you'll get:

St ti ij jl ..  
Sti tij ijl jla ..

But you can still match "Stijlaart", because you'll match "st" AND ti"  
AND "ij" etc.

I'm not sure how the scoring for that will compare to having an nGram  
tokenizer that's long enough to fully include the term you're  
searching for, but for getting a match you don't need to do what you  
suggested.

I have a combination of trigram and 2..3gram nGram filters to to fuzzy  
matching on arbitrary text that usually includes words longer than  
that.

---

<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:25am UTC](https://discuss.elastic.co/t/long-words-matching/7961/3 "2017-07-06T03:25:44Z")

</div>


