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.