lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject MultiField Query
Date Sun, 16 Jul 2006 18:25:19 GMT
I am using Lucene 2.0 and trying to use the MultiFieldQueryParser 
in my search.
I want to limit my search to documents which have "silly"
in "field1" ...within that subset of documents, I want documents which
"example" in "field2" OR "field3"
The code fragment below is my attempt at this ...code blows
on the : Query query = qp.parse(... 
statement ...
Besides blowing, I believe that the MUST / MUST for field2 and field3
is inappropriate ...I really want to say ..if field1 has "silly"
return documents with "example" in field2 OR field3.

Any suggestions for accomplishing this ? 
Someone suggested BooleanQuery but I was not sure how to merge
that concept in with the MultiFieldQueryParser ..

if (fsDir != null) {
 IndexSearcher is = new IndexSearcher(fsDir);
 MultiFieldQueryParser qp == new MultiFieldQueryParser(searchFields,new
 // Is a Lucene IndexSearcher object available
 if (qp != null) {
     String [] searchTerms   = {"silly",  "example"};             //
search terms
     String [] searchFields  = {"field1", "field2", "field3"};    //
search field names
     //   silly MUST occur in field1 - example SHOULD occur in field2
     BooleanClause.Occur [] booleanClauses = 
                             { BooleanClause.Occur.MUST,    
     Query query = qp.parse(searchTerms, searchFields, booleanClauses,
new StopAnalyzer());;

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message