# Elastic search wildcard search space issue

**URL:** <https://discuss.elastic.co/t/elastic-search-wildcard-search-space-issue/274263>\
**Category:** Elasticsearch\
**Created:** [May 27, 2021, 8:28pm UTC](https://discuss.elastic.co/t/elastic-search-wildcard-search-space-issue/274263 "2021-05-27T20:28:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mithoon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mithoon/32/78018_2.png) [@Mithoon](https://discuss.elastic.co/u/Mithoon)\
**Post date:** [May 27, 2021, 8:28pm UTC](https://discuss.elastic.co/t/elastic-search-wildcard-search-space-issue/274263/1 "2021-05-27T20:28:34Z")

</div>

Consider index field " **ProductName**" having the value " **dove 3.75oz**" and when user searches for "dove 3.75oz" text below bool query is working fine to retreive the document:

{"bool":{"must":[{"wildcard":{"ProductName":{"value":" _dove_ "}}},{"wildcard":{"ProductName":{"value":" _3.75oz_ "}}}]}}

If user searches for "dove 3.75 oz" ( **Space between "3.75" and "oz"** ) the bool query is failing to retrieve the same document:

{"bool":{"must":[{"wildcard":{"ProductName":{"value":" _dove_ "}}},{"wildcard":{"ProductName":{"value":" _3.75 oz_ "}}}]}}

Question: How to design a query using a wildcard query that supports space or no spaces? Please share an example.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 31, 2021, 7:53am UTC](https://discuss.elastic.co/t/elastic-search-wildcard-search-space-issue/274263/2 "2021-05-31T07:53:26Z")

</div>

The key here is not so much about the search, but getting the part to store the data right. I highly encourage you to read about [Analysis](https://www.elastic.co/guide/en/elasticsearch/reference/7.13/analysis.html) as this is crucial to get a good search up and running.

---

<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:** [June 28, 2021, 7:53am UTC](https://discuss.elastic.co/t/elastic-search-wildcard-search-space-issue/274263/3 "2021-06-28T07:53:37Z")

</div>

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