Query to be used to find substring in a column


(Nitin) #1

Hi,

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.

Regards


(David Pilato) #2

I would use a ngram based analyzer.


(Nitin) #3

I am using QueryBuilders.wildcardQuery
works well for me.

Thanks


(David Pilato) #4

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


(Nitin) #5

how about matchPhrasePrefixQuery ? Is it also bad?


(system) #6