# Preventing ngram on query term

**URL:** <https://discuss.elastic.co/t/preventing-ngram-on-query-term/16387>\
**Category:** Elasticsearch\
**Created:** [March 14, 2014, 11:08pm UTC](https://discuss.elastic.co/t/preventing-ngram-on-query-term/16387 "2014-03-14T23:08:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ymous\_anon1234](https://avatars.discourse-cdn.com/v4/letter/y/278dde/32.png) [@ymous\_anon1234](https://discuss.elastic.co/u/ymous_anon1234)\
**Post date:** [March 14, 2014, 11:08pm UTC](https://discuss.elastic.co/t/preventing-ngram-on-query-term/16387/1 "2014-03-14T23:08:04Z")

</div>

How would you disable the ngramming of the query term:  
"match": {"username.ngram": "linus"

the indexer:  
"tokenizer": {"customNgram": {"type": "nGram", "min\_gram": 3, "max\_gram":  
5}

I don't want hits for lin, inu, nus as in Xinus but I do want hits for  
tlinustorvalds

In other words - I don't what the query term "linus" to be broken down to  
[4-2]-grams

Thanks very much.

--  
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/196100e8-478c-4eb0-b285-68c3a59c0dbc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/196100e8-478c-4eb0-b285-68c3a59c0dbc%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 15, 2014, 3:11am UTC](https://discuss.elastic.co/t/preventing-ngram-on-query-term/16387/2 "2014-03-15T03:11:08Z")

</div>

In [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-match-query.html:](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-match-query.html:)

The analyzer can be set to control which analyzer will perform the analysis process on the text. It default to the field explicit mapping definition, or the default search analyzer.

Also you can define in your mapping a different analyzer for indexing and searching:

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html)

index\_analyzer

The analyzer used to analyze the text contents when analyzed during indexing.

search\_analyzer

The analyzer used to analyze the field when part of a query string. Can be updated on an existing field.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 15 mars 2014 à 00:08, [ymous.anon1234@gmail.com](mailto:ymous.anon1234@gmail.com) a écrit :

How would you disable the ngramming of the query term:  
"match": {"username.ngram": "linus"

the indexer:  
"tokenizer": {"customNgram": {"type": "nGram", "min\_gram": 3, "max\_gram": 5}

I don't want hits for lin, inu, nus as in Xinus but I do want hits for tlinustorvalds

In other words - I don't what the query term "linus" to be broken down to [4-2]-grams

## Thanks very much.

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/196100e8-478c-4eb0-b285-68c3a59c0dbc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/196100e8-478c-4eb0-b285-68c3a59c0dbc%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/57EE8F2E-AE14-4FA2-B1E7-E545AFF63134%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/57EE8F2E-AE14-4FA2-B1E7-E545AFF63134%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:43am UTC](https://discuss.elastic.co/t/preventing-ngram-on-query-term/16387/3 "2017-07-06T01:43:03Z")

</div>


