I am implementing a typeahead feature in our system where our customers can search for products in their own products catalog.
I created a text search index on the name of the product with a custom analyzer (single tokenizer and toLower filter)
I am doing a regex query with a limit of 500 in order to return all the products that contain the search value somewhere in the product name.
For example. if a user searches for “drink” the regex query I am doing is - .*drink.*
Basically, it works really good, but when the user searches for something with a lot of results I get an error: TooManyClauses[maxClauseCount is set to 1024]
This is an example of a query I am doing:
curl -XPOST -H “Content-Type: application/json”
We have 8172 documents for “Bosch” products. I am aware of the reason why I get the “TooManyClauses” err (at least I think so), but nevertheless, I want to get only 500 documents and not all the results.
Is there a way to get some results without getting the “TooManyClauses” error?