MultiFieldQueryParser
is what you want, as you say.
Make sure:
- The field names are always used consistently
- The same
Analyzer
is used on both fields, and also on the query parser - You won't find partial words by default, so if you search for
jack
you won't findjackson
. (You can search forjack*
in that case.)
Regarding field name, I always set up an enum
for my field names, then use e.g. MyFieldEnum.firstname.name()
when passing field names to Lucene, so that if I make a spelling mistake the compiler can catch it, and it's also a good place to put Javadoc so you can see what the fields are for, and also a place where you can see the complete list of fields you wish to support in your Lucene documents.
Read full article from java - Searching multiple fields with Lucene - Stack Overflow
No comments:
Post a Comment