lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ranjit Kumar <>
Subject Re: lucene3.0.3 | get correct document in case of multiple Boolean query in search criteria
Date Tue, 22 Feb 2011 09:49:25 GMT

As, mention above i am using query like:

criteria = (sql OR sqlserver OR "sql server") AND java AND delphi

In the above scenario i need hit(document) containing at least one occurrence of (sql OR sqlserver
OR "sql server"). Also java and delphi must present in document.

Still I have not got solution for that!!

but, if my query changes to:

criteria = sql OR sqlserver OR "sql server" AND java AND delphi

we can use MultiFieldQueryParser in this way ==>

String[] queree = {"sql ", "sqlserver ","sql server","java ","delphi"};

String[] fields = {"contents","contents","contents","contents","contents"};

BooleanClause.Occur[] flags={BooleanClause.Occur.SHOULD,BooleanClause.Occur.SHOULD,BooleanClause.Occur.SHOULD,BooleanClause.Occur.MUST,

Query query = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, queree, fields, flags, analyzer);

TopDocs docs =, null, n);

System.out.println("Total document matched: "+docs.totalHits);

          **It gives correct document!!**

suggest me to get hit(document) in the context mention in my first query!!

Thanks & Regards,
Ranjit Kumar
Private, Confidential and Privileged. This e-mail and any files and attachments transmitted
with it are confidential and/or privileged. They are intended solely for the use of the intended
recipient. The content of this e-mail and any file or attachment transmitted with it may have
been changed or altered without the consent of the author. If you are not the intended recipient,
please note that any review, dissemination, disclosure, alteration, printing, circulation
or Transmission of this e-mail and/or any file or attachment transmitted with it, is prohibited
and may be unlawful. If you have received this e-mail or any file or attachment transmitted
with it in error please notify OTS Solutions at ===================================================================================================

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