# Storage problem with ngram filters

**URL:** <https://discuss.elastic.co/t/storage-problem-with-ngram-filters/105506>\
**Category:** Elasticsearch\
**Created:** [October 27, 2017, 4:18am UTC](https://discuss.elastic.co/t/storage-problem-with-ngram-filters/105506 "2017-10-27T04:18:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sidra\_89](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@sidra\_89](https://discuss.elastic.co/u/sidra_89)\
**Post date:** [October 27, 2017, 4:18am UTC](https://discuss.elastic.co/t/storage-problem-with-ngram-filters/105506/1 "2017-10-27T04:18:43Z")

</div>

Hi,

i need to search all sorts of word combinations and sub string of words through my search engine ..  
to achieve this i am using ngram filters and it is working perfectly okay but the main concern here is the storage space .. for 23000 documents it is taking upto 1.7 gb space in my local system .. i want to reduce it because the live server have many more records .. so how could i reduce this storage amount ..

anyway to use ngram in a more efficient way ?

Thanks ..

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [October 27, 2017, 5:18am UTC](https://discuss.elastic.co/t/storage-problem-with-ngram-filters/105506/2 "2017-10-27T05:18:56Z")

</div>

Unfortunately, that is the main drawback of ngrams. What are your min and  
max gram settings? Can you use an edge ngrams instead? If your max ngram  
settings is high, consider reducing it.

---

<div class="post-metadata">

**Author:** ![sidra\_89](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@sidra\_89](https://discuss.elastic.co/u/sidra_89)\
**Post date:** [October 27, 2017, 5:26am UTC](https://discuss.elastic.co/t/storage-problem-with-ngram-filters/105506/3 "2017-10-27T05:26:45Z")

</div>

right now my min and max ngram settings are : 3 - 40

but there are cases where i need longer max values ..

is there any other alternative for ngram?

any other way to match sub strings and all ? like regular expression etc

---

<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:** [October 27, 2017, 6:18am UTC](https://discuss.elastic.co/t/storage-problem-with-ngram-filters/105506/4 "2017-10-27T06:18:21Z")

</div>

You can use wildcard query but it will be slow.

---

<div class="post-metadata">

**Author:** ![sidra\_89](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@sidra\_89](https://discuss.elastic.co/u/sidra_89)\
**Post date:** [October 27, 2017, 8:47am UTC](https://discuss.elastic.co/t/storage-problem-with-ngram-filters/105506/5 "2017-10-27T08:47:13Z")

</div>

can you elaborate it a bit

what you means by wildcard query ?

and one more thing if i have a title column and it contain a phrase or a sentence so to search for that phrase or sentence is ngram the best option or there is some other way possible to do proper search for sentences and phrases ?

---

<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:** [October 27, 2017, 9:56am UTC](https://discuss.elastic.co/t/storage-problem-with-ngram-filters/105506/6 "2017-10-27T09:56:16Z")

</div>

I meant that: [https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-wildcard-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-wildcard-query.html)

---

<div class="post-metadata">

**Author:** ![sidra\_89](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@sidra\_89](https://discuss.elastic.co/u/sidra_89)\
**Post date:** [October 27, 2017, 10:20am UTC](https://discuss.elastic.co/t/storage-problem-with-ngram-filters/105506/7 "2017-10-27T10:20:49Z")

</div>

i read about this .. but it will affect the search time later on ..

and can you tell me the best way to search for phrases in elasticsearch ?

---

<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:** [October 27, 2017, 4:48pm UTC](https://discuss.elastic.co/t/storage-problem-with-ngram-filters/105506/8 "2017-10-27T16:48:16Z")

</div>

> but it will affect the search time later on ..

Yes. You always have a price to pay:

- indexing throughput and disk size (you pay at index time)
- search response time (you pay at search time)

No miracle here I'm afraid.

> and can you tell me the best way to search for phrases in elasticsearch ?

That's another question. Better to open another question.  
But here is an idea: [Match phrase query | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html)

---

<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 24, 2017, 4:48pm UTC](https://discuss.elastic.co/t/storage-problem-with-ngram-filters/105506/9 "2017-11-24T16:48:26Z")

</div>

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