lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ferdinand Chan" <ferdinand.c...@dcivision.com>
Subject Question on MutliFieldQueryParser
Date Thu, 15 Jun 2006 09:26:27 GMT
My webapp is developed with Lucene 1.4.3 and I want to upgrade the Lucene
library to version 2.0

 

But in Lucene 2.0, the MultiFieldQueryParser class was deprecated. 

 

I try to rewrite the code using a BooleanQuery as follows.

 

Original code:

 

String[] fields = {"TERM_A","TERM_B"};

query6 = MultiFieldQueryParser.parse(keyword,fields,analyzer);

 

Rewritten code:

 

QueryParser qp = new QueryParser("TERM_A",new StandardAnalyzer());

Query q1 = qp.parse(keyword);

 

qp = new QueryParser("TERM_B",new StandardAnalyzer());

Query q2 = qp.parse(keyword);

 

BooleanQuery booleanQuery = new BooleanQuery();

booleanQuery.add(q1,BooleanClause.Occur.SHOULD);

booleanQuery.add(q2,BooleanClause.Occur.SHOULD);

query6 = booleanQuery;

 

Is this correct???

 

Thanks

 

Ferdinand

 


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