# Deprecation: Deprecated big difference between max\_gram and min\_gram in NGram

**URL:** <https://discuss.elastic.co/t/deprecation-deprecated-big-difference-between-max-gram-and-min-gram-in-ngram/122969>\
**Category:** Elasticsearch\
**Created:** [March 7, 2018, 9:50pm UTC](https://discuss.elastic.co/t/deprecation-deprecated-big-difference-between-max-gram-and-min-gram-in-ngram/122969 "2018-03-07T21:50:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzlang](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jzlang](https://discuss.elastic.co/u/jzlang)\
**Post date:** [March 7, 2018, 9:50pm UTC](https://discuss.elastic.co/t/deprecation-deprecated-big-difference-between-max-gram-and-min-gram-in-ngram/122969/1 "2018-03-07T21:50:08Z")

</div>

We have a use case where we have to search a field (displayName) whose value can contain multiple words. For instance - "displayName":"Once Upon a Midnight Dreary"  
We have a requirement that auto complete functionality must work when searching any one of the words in the value, including part of a word. For instance, querying on "night" will find the above value. This means we cannot use edge\_ngram, which would only find the value if searching on "Once", or "Upo" or "Midni", etc.

We've been using the following autocomplete\_filter mapping for quite some time now which works great and meets our searching requirements:  
"analysis": { "filter": { "autocomplete\_filter": { "type": "ngram", "min\_gram": 1, "max\_gram": 10 } }

However, I noticed recently that when posting this mapping to a new index in Elasticsearch, I get the warning -  
"Deprecation: Deprecated big difference between max\_gram and min\_gram in NGram" and states that the interval between min\_gram and max\_gram needs to be \<=1.

If this is being deprecated, what is an alternative solution that would satisfy all of our requirements, notably the examples above? edge\_ngram will not work, ngram with min = 2 and max=3 will not work, as if I type "night" the above title is not found.

Also, when and what version will this be an actual breaking change? Will existing index mappings defined in this manner continue to work, but new mappings defined this way not work? How can we retain this functionality without having to reinvent the wheel?

Thank you.

---

<div class="post-metadata">

**Author:** ![Ram\_Ibaset](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ram_ibaset/32/27747_2.png) [@Ram\_Ibaset](https://discuss.elastic.co/u/Ram_Ibaset)\
**Post date:** [March 21, 2018, 12:18am UTC](https://discuss.elastic.co/t/deprecation-deprecated-big-difference-between-max-gram-and-min-gram-in-ngram/122969/2 "2018-03-21T00:18:47Z")

</div>

I have the same question and could not find an answer any where. It looks like someone had used a massive diff and it resulted in the deprecation. However, I would also like to get an answer since I am in the same quandary as you. Did you get an answer?

---

<div class="post-metadata">

**Author:** ![jzlang](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jzlang](https://discuss.elastic.co/u/jzlang)\
**Post date:** [March 21, 2018, 4:30pm UTC](https://discuss.elastic.co/t/deprecation-deprecated-big-difference-between-max-gram-and-min-gram-in-ngram/122969/3 "2018-03-21T16:30:03Z")

</div>

I haven't found any answers or received any recommendations. We convinced the business to use edge\_ngram for now for our use case though, as it at least allows a starts with search for each word in a phrase.

---

<div class="post-metadata">

**Author:** ![Ram\_Ibaset](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ram_ibaset/32/27747_2.png) [@Ram\_Ibaset](https://discuss.elastic.co/u/Ram_Ibaset)\
**Post date:** [March 21, 2018, 4:32pm UTC](https://discuss.elastic.co/t/deprecation-deprecated-big-difference-between-max-gram-and-min-gram-in-ngram/122969/4 "2018-03-21T16:32:45Z")

</div>

Thanks. I feel that this will be a problem and posted a comment on the GIT issues. Our mandate is to be able to do wildcard like searches and one of the reasons we moved away is because SQL text searches bog the DBMS down. This limitation should be down voted and instead the developer uses his/her discretion. I don't see an option and I cant get any answers either.

---

<div class="post-metadata">

**Author:** ![jzlang](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jzlang](https://discuss.elastic.co/u/jzlang)\
**Post date:** [March 21, 2018, 4:50pm UTC](https://discuss.elastic.co/t/deprecation-deprecated-big-difference-between-max-gram-and-min-gram-in-ngram/122969/5 "2018-03-21T16:50:41Z")

</div>

There is another option I considered trying but I have not tried it yet and not even sure it is possible -  
using an edge\_ngram analyzer of 2-10 or even 2-20 which would handle the "starts with" searching of each word, and adding an ngram analyzer of 2-3 to handle "contains" and "ends-with" searching of 2-3 characters. Not sure if it is possible to have two analyzers on one field, but it may be worth a try.

---

<div class="post-metadata">

**Author:** ![\_markus](https://avatars.discourse-cdn.com/v4/letter/_/ecb155/32.png) [@\_markus](https://discuss.elastic.co/u/_markus)\
**Post date:** [March 22, 2018, 2:54pm UTC](https://discuss.elastic.co/t/deprecation-deprecated-big-difference-between-max-gram-and-min-gram-in-ngram/122969/6 "2018-03-22T14:54:23Z")

</div>

I've changed the index setting `max_ngram_diff` as documented at [https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-ngram-tokenizer.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-ngram-tokenizer.html) to "fix" that deprecation message.

---

<div class="post-metadata">

**Author:** ![jzlang](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jzlang](https://discuss.elastic.co/u/jzlang)\
**Post date:** [March 22, 2018, 4:40pm UTC](https://discuss.elastic.co/t/deprecation-deprecated-big-difference-between-max-gram-and-min-gram-in-ngram/122969/7 "2018-03-22T16:40:24Z")

</div>

Thanks Markus. Will try that if we need to go back to ngram for business reasons.

---

<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:** [April 19, 2018, 4:40pm UTC](https://discuss.elastic.co/t/deprecation-deprecated-big-difference-between-max-gram-and-min-gram-in-ngram/122969/8 "2018-04-19T16:40:29Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
