lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Warren <war...@clarksnutrition.com>
Subject BooleanQuery questions
Date Wed, 03 Oct 2007 22:30:50 GMT
I am new to Lucene and am having problems with booleanQueries. How do you write Boolean OR
and AND 
queries?

Is this an OR query

booleanQuery.add(query1, BooleanClause.Occur.SHOULD);
booleanQuery.add(query2, BooleanClause.Occur.SHOULD);

and is this an AND query

booleanQuery.add(query1, BooleanClause.Occur.MUST);
booleanQuery.add(query2, BooleanClause.Occur.MUST);

Is there a problem writing it this way so I can change between the two by setting booleanANDSearch

to true or false

booleanQuery.add(query1,(booleanANDSearch?BooleanClause.Occur.MUST:BooleanClause.Occur.SHOULD));
booleanQuery.add(query2,(booleanANDSearch?BooleanClause.Occur.MUST:BooleanClause.Occur.SHOULD));

Also, when I call booleanQuery.toString(), I am getting this:

(upc:creatine description:creatine content:creatine) (brand:gluten brand:free) (category:alc

category:beer)

It looks like each grouping is a query but how are the queries connected, with AND, OR or
NOT?

-- 
Thanks,

Warren Bell

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message