# Limit ngram tokenizer

**URL:** <https://discuss.elastic.co/t/limit-ngram-tokenizer/80878>\
**Category:** Elasticsearch\
**Created:** [March 31, 2017, 10:44pm UTC](https://discuss.elastic.co/t/limit-ngram-tokenizer/80878 "2017-03-31T22:44:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![venkata\_sreekanth\_bh](https://avatars.discourse-cdn.com/v4/letter/v/65b543/32.png) [@venkata\_sreekanth\_bh](https://discuss.elastic.co/u/venkata_sreekanth_bh)\
**Post date:** [March 31, 2017, 10:44pm UTC](https://discuss.elastic.co/t/limit-ngram-tokenizer/80878/1 "2017-03-31T22:44:45Z")

</div>

POST \_analyze  
{  
"tokenizer": {"type":"ngram",  
"min\_gram":"3",  
"max\_gram":"50"},  
"text": "12345678"  
}

{  
"tokens": [  
{  
"token": "123",  
"start\_offset": 0,  
"end\_offset": 3,  
"type": "word",  
"position": 0  
},  
{  
"token": "1234",  
"start\_offset": 0,  
"end\_offset": 4,  
"type": "word",  
"position": 1  
},  
{  
"token": "12345",  
"start\_offset": 0,  
"end\_offset": 5,  
"type": "word",  
"position": 2  
},  
{  
"token": "123456",  
"start\_offset": 0,  
"end\_offset": 6,  
"type": "word",  
"position": 3  
},  
{  
"token": "1234567",  
"start\_offset": 0,  
"end\_offset": 7,  
"type": "word",  
"position": 4  
},  
{  
"token": "12345678",  
"start\_offset": 0,  
"end\_offset": 8,  
"type": "word",  
"position": 5  
},  
{  
"token": "234",  
"start\_offset": 1,  
"end\_offset": 4,  
"type": "word",  
"position": 6  
},  
{  
"token": "2345",  
"start\_offset": 1,  
"end\_offset": 5,  
"type": "word",  
"position": 7  
},  
{  
"token": "23456",  
"start\_offset": 1,  
"end\_offset": 6,  
"type": "word",  
"position": 8  
},  
{  
"token": "234567",  
"start\_offset": 1,  
"end\_offset": 7,  
"type": "word",  
"position": 9  
},  
{  
"token": "2345678",  
"start\_offset": 1,  
"end\_offset": 8,  
"type": "word",  
"position": 10  
},  
{  
"token": "345",  
"start\_offset": 2,  
"end\_offset": 5,  
"type": "word",  
"position": 11  
},  
{  
"token": "3456",  
"start\_offset": 2,  
"end\_offset": 6,  
"type": "word",  
"position": 12  
},  
{  
"token": "34567",  
"start\_offset": 2,  
"end\_offset": 7,  
"type": "word",  
"position": 13  
},  
{  
"token": "345678",  
"start\_offset": 2,  
"end\_offset": 8,  
"type": "word",  
"position": 14  
},  
{  
"token": "456",  
"start\_offset": 3,  
"end\_offset": 6,  
"type": "word",  
"position": 15  
},  
{  
"token": "4567",  
"start\_offset": 3,  
"end\_offset": 7,  
"type": "word",  
"position": 16  
},  
{  
"token": "45678",  
"start\_offset": 3,  
"end\_offset": 8,  
"type": "word",  
"position": 17  
},  
{  
"token": "567",  
"start\_offset": 4,  
"end\_offset": 7,  
"type": "word",  
"position": 18  
},  
{  
"token": "5678",  
"start\_offset": 4,  
"end\_offset": 8,  
"type": "word",  
"position": 19  
},  
{  
"token": "678",  
"start\_offset": 5,  
"end\_offset": 8,  
"type": "word",  
"position": 20  
}  
]  
}

I would like to stop the ngram tokenizer after it has finished ngramming 4. How can I achieve that ?

I would like to stop ngramming after this token

{  
"token": "45678",  
"start\_offset": 3,  
"end\_offset": 8,  
"type": "word",  
"position": 17  
}

---

<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 28, 2017, 10:44pm UTC](https://discuss.elastic.co/t/limit-ngram-tokenizer/80878/2 "2017-04-28T22:44:48Z")

</div>

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