# Min shingle size

**URL:** <https://discuss.elastic.co/t/min-shingle-size/79348>\
**Category:** Elasticsearch\
**Created:** [March 21, 2017, 5:16am UTC](https://discuss.elastic.co/t/min-shingle-size/79348 "2017-03-21T05:16:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vapostolov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vapostolov/32/16533_2.png) [@vapostolov](https://discuss.elastic.co/u/vapostolov)\
**Post date:** [March 21, 2017, 5:16am UTC](https://discuss.elastic.co/t/min-shingle-size/79348/1 "2017-03-21T05:16:37Z")

</div>

Hello,

I am currently researching how to optimize my queries using n-grams. I decided to use Elasticsearch to generate the n-grams, so I set up a trial account. I managed to get n-grams from a sample string, but I got the following error message:

Min shingle size must be \>= 2

I am afraid I need shingles with size 1, so I want to ask whether that is possible. Do you think it is appropriate to use Elasticsearch to get n-grams as shingles?

Thank you.

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [March 21, 2017, 3:07pm UTC](https://discuss.elastic.co/t/min-shingle-size/79348/2 "2017-03-21T15:07:44Z")

</div>

I'm somewhat confused, are you attempting to use n-grams with size one, or shingles with size one?

---

<div class="post-metadata">

**Author:** ![vapostolov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vapostolov/32/16533_2.png) [@vapostolov](https://discuss.elastic.co/u/vapostolov)\
**Post date:** [March 21, 2017, 3:25pm UTC](https://discuss.elastic.co/t/min-shingle-size/79348/3 "2017-03-21T15:25:24Z")

</div>

I meant shingles, sorry.

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [March 22, 2017, 5:56pm UTC](https://discuss.elastic.co/t/min-shingle-size/79348/4 "2017-03-22T17:56:00Z")

</div>

No problem 🙂

You can configure `output_unigrams: true` if you want the shingle filter to always emit the unigram shingle token. Or you can configure `output_unigrams_if_no_shingles: true` if you want the unigram to be emitted only when there aren't multi-gram shingles.

There's more detail at the docs page: [https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-shingle-tokenfilter.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-shingle-tokenfilter.html)

---

<div class="post-metadata">

**Author:** ![vapostolov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vapostolov/32/16533_2.png) [@vapostolov](https://discuss.elastic.co/u/vapostolov)\
**Post date:** [March 23, 2017, 6:21am UTC](https://discuss.elastic.co/t/min-shingle-size/79348/5 "2017-03-23T06:21:05Z")

</div>

Thank you.

---

<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 20, 2017, 6:21am UTC](https://discuss.elastic.co/t/min-shingle-size/79348/6 "2017-04-20T06:21:35Z")

</div>

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