Elastic Query Issue

We initially implemented proximity search using wildcard queries in Elasticsearch, but this approach couldn't accommodate all of our functional use cases. In some scenarios, we encountered an error due to the 128 combination limit (i.e. elastic error), particularly when using asterisks (*) along with proximity operators (NEAR and ADJ). The error didn't occur when using Boolean operators (AND, OR, NOT). To resolve this issue, we switched from wildcard queries to prefix queries.

However, when we attempted to execute proximity queries along with truncation operators using prefix queries, we encountered failures again. To address this, we found a solution: limiting the number of terms in the prefix query within the range of 0 to 20. This adjustment allowed us to perform successful searches, but this change resulted in a significant increase in the index size and overall costs.

I'm tackling similar issues with my queries currently. One of the things that has made things worse is my use of shingles in the index - it leads to many more unique terms that need to be considered. If you also use them that might be something you might want to reconsider as they will mean more disk space if you opt for the index-time "index-prefixes" solution or more query failures if you just rely on the query-time prefix expansion.

Any Solution or workaround as it just increases the index size 5-6 times.

Do you use shingles?
I opened this issue with a suggested change to elasticsearch