# Ngram indexing and search results quality

**URL:** https://discuss.elastic.co/t/ngram-indexing-and-search-results-quality/16201
**Category:** Elasticsearch
**Created:** [March 6, 2014, 5:01pm UTC](https://discuss.elastic.co/t/ngram-indexing-and-search-results-quality/16201 "2014-03-06T17:01:50Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Nadav\_Samet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nadav_samet/32/1761_2.png) [@Nadav\_Samet](https://discuss.elastic.co/u/Nadav_Samet)
#### Post date: [March 6, 2014, 5:01pm UTC](https://discuss.elastic.co/t/ngram-indexing-and-search-results-quality/16201/1 "2014-03-06T17:01:50Z")

</div>

Hi,

I am indexing using an nGram filter and it seems to be working - I am able  
to find substrings of words. However, I have noticed that documents that  
contain only a substring of the term I am looking for are ranked above  
documents who have an exact match. For instance, if I search for "rain", I  
can get a document that contains the word "brainstorm" above a document  
that contains the exact term "rain".

Is there a way to have exact matches score more? Similarly, is there a way  
to boost the score of ngrams that contain the first letter?

Thanks,  
Nadav

For reference, here are the settings I put on the index:

{  
"settings": {  
"analysis": {  
"filter": {  
"nGram\_filter": {  
"type": "nGram",  
"min\_gram": 2,  
"max\_gram": 20,  
"token\_chars": [  
"letter",  
"digit",  
"punctuation",  
"symbol"  
]  
}  
},  
"analyzer": {  
"nGram\_analyzer": {  
"type": "custom",  
"tokenizer": "whitespace",  
"filter": [  
"lowercase",  
"asciifolding",  
"nGram\_filter"  
]  
},  
"whitespace\_analyzer": {  
"type": "custom",  
"tokenizer": "whitespace",  
"filter": [  
"lowercase",  
"asciifolding"  
]  
}  
}  
}  
},  
"mappings": {  
"person": {  
"\_all": {  
"index\_analyzer": "nGram\_analyzer",  
"search\_analyzer": "whitespace\_analyzer"  
},  
"properties": { .. }  
}  
}  
}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7f4e0609-de8d-4e72-8608-3d53f4ade40c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7f4e0609-de8d-4e72-8608-3d53f4ade40c%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 1:45am UTC](https://discuss.elastic.co/t/ngram-indexing-and-search-results-quality/16201/2 "2017-07-06T01:45:18Z")

</div>


