# nGram filter and relevance score

**URL:** <https://discuss.elastic.co/t/ngram-filter-and-relevance-score/22475>\
**Category:** Elasticsearch\
**Created:** [March 2, 2015, 7:10pm UTC](https://discuss.elastic.co/t/ngram-filter-and-relevance-score/22475 "2015-03-02T19:10:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Torben](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@Torben](https://discuss.elastic.co/u/Torben)\
**Post date:** [March 5, 2015, 8:56pm UTC](https://discuss.elastic.co/t/ngram-filter-and-relevance-score/22475/2 "2015-03-05T20:56:40Z")

</div>

If anyone is interested:

I resolved this issue by replacing the nGram filter with a nGram tokenizer:

{  
"settings": {  
"number\_of\_shards": 1,  
"number\_of\_replicas": 0,  
"analysis": {  
"analyzer": {  
"my\_index\_analyzer": {  
"type": "custom",  
"tokenizer": "my\_ngram\_tokenizer",  
"filter": [  
"lowercase"  
]  
},  
"my\_search\_analyzer": {  
"type": "custom",  
"tokenizer": "whitespace",  
"filter": [  
"lowercase"  
]  
}  
},  
"tokenizer" : {  
"my\_ngram\_tokenizer" : {  
"type" : "nGram",  
"min\_gram" : "1",  
"max\_gram" : "50"  
}  
}  
}  
}  
}

Now, the term "barfoobar" has a higher score than "blablablafoobarbarbar".

--  
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/521b01f1-c33f-4444-a618-edb458cd6717%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/521b01f1-c33f-4444-a618-edb458cd6717%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

_[View the full topic](https://discuss.elastic.co/t/ngram-filter-and-relevance-score/22475)._
