# How to decide between regex and wildcard for a scenario

**URL:** https://discuss.elastic.co/t/how-to-decide-between-regex-and-wildcard-for-a-scenario/202902
**Category:** Elasticsearch
**Created:** [October 9, 2019, 7:00pm UTC](https://discuss.elastic.co/t/how-to-decide-between-regex-and-wildcard-for-a-scenario/202902 "2019-10-09T19:00:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Seetha93](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@Seetha93](https://discuss.elastic.co/u/Seetha93)
#### Post date: [October 9, 2019, 7:00pm UTC](https://discuss.elastic.co/t/how-to-decide-between-regex-and-wildcard-for-a-scenario/202902/1 "2019-10-09T19:00:17Z")

</div>

When we are trying to do a regex on around 10 different terms, we get the following exception:

`ElasticsearchException[Elasticsearch exception [type=too_complex_to_determinize_exception, reason=too_complex_to_determinize_exception: Determinizing automaton with 67 states and 278 transitions would result in more than 10000 states.]];`

Increasing the boost will resolve the error. But the number of terms passed will differ and cant fix a specific value. I am thinking of using wildcard.

Wildcard also internally creates states, so whether using wild card is a better approach or is there a better way?

My sample query using regex:

```
search {"from":0,"size":0,"timeout":"60s","query":{"bool":{"must":[{"regexp":{"filed_name":

{"value":".*term.*|.*term.*|.*term.*|.*term.*|.*term.*|.*term.*|.*term.*|.*term.*|.*term.*|.*term.*|.*term.*","flags_value":65535,"max_determinized_states":10000,"boost":1.0}

}},{"range":{"condition_field":

{"from":0,"to":null,"include_lower":false,"include_upper":true,"boost":1.0}

}},{"range":{"condition_filed":

{"from":0,"to":null,"include_lower":false,"include_upper":true,"boost":1.0}

}}],"adjust_pure_negative":true,"boost":1.0}},"profile":true,"sort":[{"_id":{"order":"asc"}}]}
```

---

<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 6, 2019, 7:00pm UTC](https://discuss.elastic.co/t/how-to-decide-between-regex-and-wildcard-for-a-scenario/202902/2 "2019-11-06T19:00:19Z")

</div>

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