# Shingles vs phrases for index size

**URL:** https://discuss.elastic.co/t/shingles-vs-phrases-for-index-size/152137
**Category:** Elasticsearch
**Created:** [October 11, 2018, 10:55pm UTC](https://discuss.elastic.co/t/shingles-vs-phrases-for-index-size/152137 "2018-10-11T22:55:18Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![doaks](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@doaks](https://discuss.elastic.co/u/doaks)
#### Post date: [October 11, 2018, 10:55pm UTC](https://discuss.elastic.co/t/shingles-vs-phrases-for-index-size/152137/1 "2018-10-11T22:55:19Z")

</div>

I am looking at using either shingles or phrases to allow phrase queries, however it seems to me that shingles must have a massive impact on index size. This is acknowledged in the documentation ([https://www.elastic.co/blog/searching-with-shingles](https://www.elastic.co/blog/searching-with-shingles)) "The downside is that you have larger indices...". However it seems that the indexes won't be just large, but massively so.

Given that phrase queries are reasonably efficient, especially for rare word combinations that will often narrow down to a single document before even looking at a word-ordered phrase, is shingles really with the massively bloated index that comes with them?

---

<div class="post-metadata">

### Author: ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)
#### Post date: [October 14, 2018, 3:29am UTC](https://discuss.elastic.co/t/shingles-vs-phrases-for-index-size/152137/2 "2018-10-14T03:29:53Z")

</div>

Hi Daniel,

> [@doaks](#):
>
> is shingles really with the massively bloated index that comes with them?

Unfortunately, no one can really answer that for you. You'll need to test with your data so that you can determine whether the search performance of phrase queries (which, as you said, is reasonably efficient) is acceptable. If it is not, then shingles may be a tradeoff you want to check into.

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [October 14, 2018, 8:34am UTC](https://discuss.elastic.co/t/shingles-vs-phrases-for-index-size/152137/3 "2018-10-14T08:34:32Z")

</div>

One advantage of shingles over single terms is that Lucene will store the frequency of the word pair rather than just the frequencies of the individual terms.  
Search ranking and discovery of phrases (using the significant\_text aggregation) is improved when phrases are given their true worth through shingles. A phrase like “global warming” will be scored and presented (in significant text discovery) as a whole concept rather than, individual terms like “global” which on their own are boring. The fact that significant\_text discovers and presents word-pairs is especially useful for finding names of people strongly connected with a topic.  
I tend to stick with max shingle size of 2 because it’s a sweet spot for the costs/benefits

---

<div class="post-metadata">

### Author: ![doaks](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@doaks](https://discuss.elastic.co/u/doaks)
#### Post date: [October 15, 2018, 5:06am UTC](https://discuss.elastic.co/t/shingles-vs-phrases-for-index-size/152137/4 "2018-10-15T05:06:06Z")

</div>

@Mark_Harwood thanks that makes sense about frequencies. To clarify the connection between phrases and shingles, if I use match\_phrase will it automatically try and match against shingles before trying positional phrase matching? What about plain "match" (default bool OR) - does it care about shingles at all?

---

<div class="post-metadata">

### Author: ![AlanWoodward](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alanwoodward/32/41962_2.png) [@AlanWoodward](https://discuss.elastic.co/u/AlanWoodward)
#### Post date: [October 15, 2018, 8:21am UTC](https://discuss.elastic.co/t/shingles-vs-phrases-for-index-size/152137/5 "2018-10-15T08:21:24Z")

</div>

It depends on the output of your analysis chain. If you've configured things to produce shingles, then a query like "global warming" will get analyzed to a single term and so will produce a term query. For a shingle setting of 3, "catastrophic global warming" would also get analyzed to a single term, but with a setting of 2, it will be analyzed to two terms "catastrophic global" and "global warming", and produce a positional query. Neither match\_phrase or match care about shingles as such, they just operate on the outputs of the query analyzer.

Note that there's been an 'index\_phrases' option on text fields since 6.3, which handles shingling behind the scenes so that you don't need to worry about analysis configuration - see under [https://www.elastic.co/guide/en/elasticsearch/reference/current/text.html#text-params](https://www.elastic.co/guide/en/elasticsearch/reference/current/text.html#text-params)

---

<div class="post-metadata">

### Author: ![doaks](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@doaks](https://discuss.elastic.co/u/doaks)
#### Post date: [October 15, 2018, 8:54pm UTC](https://discuss.elastic.co/t/shingles-vs-phrases-for-index-size/152137/6 "2018-10-15T20:54:08Z")

</div>

> [@AlanWoodward](#):
>
> output of your analysis chain. If you've configured things to produce shingles, then a query like "global warming" will get analyzed to a single term and so will produce a term query. For a shingle setting of 3, "catastrophic global warming" would also get analyzed to a single term, but with a setting of 2, it will be analyzed to two terms "catastrophic global" and "global warming", and produce a positional query. Neither match\_p

Thanks.

---

<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: [November 12, 2018, 8:54pm UTC](https://discuss.elastic.co/t/shingles-vs-phrases-for-index-size/152137/7 "2018-11-12T20:54:08Z")

</div>

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