lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Van Nguyen" <vngu...@ur.com>
Subject BooleanQuery question
Date Thu, 06 Jul 2006 19:57:24 GMT
I have a BooleanQuery that looks like this:

 

BooleanQuery query = new BooleanQuery();

 

TermQuery term1 = new TermQuery(new Term(ID, "1234"));

TermQuery term2 = new TermQuery(new Term(ID, "2344"));

TermQuery term2 = new TermQuery(new Term(ID, "2323"));

TermQuery termLocation = new TermQuery(new Term(LOCATION, "A1"));

TermQuery termLanguage = new TermQuery(new Term(LANGUAGE, "ENU"));

 

query.add(term1, BooleanClause.Occur.Should);

query.add(term2, BooleanClause.Occur.Should);

query.add(term3, BooleanClause.Occur.Should);

query.add(termLocation, BooleanClause.Occur.MUST);

query.add(termLanguage, BooleanClause.Occur.MUST);

 

It produces this:

 

ID: 1234 ID:2344 ID:2323 +LOCATION:A1 +LANGUAGE:ENU

 

I just want results that have:

ID: 1234 OR 2344 OR 2323

LOCATION: A1 

LANGUAGE: ENU

 

This query returns everything from my index.  How would I create a query
that will only return results the must have LOCATION and LANGUAGE and
have only those three IDs.


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