# Wildcard searches crashing ElasticSearch Server

**URL:** <https://discuss.elastic.co/t/wildcard-searches-crashing-elasticsearch-server/158300>\
**Category:** Elasticsearch\
**Created:** [November 27, 2018, 8:53am UTC](https://discuss.elastic.co/t/wildcard-searches-crashing-elasticsearch-server/158300 "2018-11-27T08:53:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anurag\_Kumar1](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@Anurag\_Kumar1](https://discuss.elastic.co/u/Anurag_Kumar1)\
**Post date:** [November 27, 2018, 8:53am UTC](https://discuss.elastic.co/t/wildcard-searches-crashing-elasticsearch-server/158300/1 "2018-11-27T08:53:58Z")

</div>

I have a deployment of ~30 node ES Cluster, where the index size density is roughly 2 TB per node.  
We have a use-case of some ES node regularly crashing when our end-user triggers wildcard searches. (ES node goes OOM)

While we are putting some guardrails in UI to stop user from doing bad searches(for ex: if somebody only searches with \*), my question is that is there a way to upfront predict a bad search request & terminate it, instead of crashing the server,

The memory usage based on heapdump seems to be mainly around the # of possible expansions, these wildcard searches generates.  
For ex : ru\* generating 1M+ expansions.

I came across "Multi-Term Query Rewrite" option below. It looks compelling enough to try, i.e. try to limit the # of possible expansions of a wildcard search upfront, instead of allowing it to expand in an unlimited fashion.

[https://www.elastic.co/guide/en/elasticsearch/reference/2.4/query-dsl-multi-term-rewrite.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/query-dsl-multi-term-rewrite.html)

Has anyone used this option for a similar use-case ?  
Will it help drastically improving the reliability of my ES nodes going OOM ?

Note : We use span\_multi queries for the business use-case we support. (ES Version 2.4)

---

<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:** [December 25, 2018, 8:54am UTC](https://discuss.elastic.co/t/wildcard-searches-crashing-elasticsearch-server/158300/2 "2018-12-25T08:54:00Z")

</div>

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