Elastic search wildcard search space issue

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.

1 Like

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 as this is crucial to get a good search up and running.

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