Query to be used to find substring in a column


I have a field as TAGS which contains various tags for an indexed document.
I have to search over these tags and if the entered string matches partially or fully to any of these tags then search result should display the document details.
Example- My TAGS field for a document contains: "chocolate sweet maxys birthday default"
Then all these terms in search should result in this document. choc or sweet or d or def.
Just like we get in head plugin's browser tab.

Any help for Java QueryBuilder would be helpful.


I would use a ngram based analyzer.

I am using QueryBuilders.wildcardQuery
works well for me.


Well. Super inefficient. If you don't have too many terms, that might work but really it's better to use ngrams.

how about matchPhrasePrefixQuery ? Is it also bad?