lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jay Joel Malaluan <>
Subject Re: Unique results in BooleanQuery
Date Fri, 19 Dec 2008 10:22:13 GMT
Hi Chris,

I was just thinking that when the 1st query of q2 is run it will have its result. 
Then the 2nd query of q2 will run and have its own result BUT it is now filtered that no same
data from the 1st query is returned. 
Results of the 1st and 2nd query have been appended.

Does the 2nd query of q2 have two process?
1. Run the query to get results.
2. For filtering


From: Chris Hostetter <>
Sent: Thursday, December 18, 2008 3:14:51 PM
Subject: Re: Unique results in BooleanQuery

: Let me expound more on the question. Will the q1 be run on the 
: BooleanQuery q2 and append the results that are not equal to the result 
: of the first query of q2?

i really have no idea what you mean by: "q1 be run on the BooleanQuery q2"

the query structure suggested will ensure that you only get results which 
match q2 and do not match q1 (per your request "then the 2nd query will 
not anymore return the same results from the 1st query")

: Do the first query as normal, then create a second BooleanQuery; add one clause for "colour:blue",
Occur.MUST, and then add the query from the first search as a MUST_NOT.
: Query q1 = new TermQuery(new Term("fruit", "apple"));
: ..... run query, get back all apples ...
: BooleanQuery q2 = new BooleanQuery();
: q2.add(new TermQuery(new Term("colour", "blue")), Occur.MUST);
: q2.add(q1, Occur.MUST_NOT);
: ..... run query q2, get back all blue things that don't have apples ...


To unsubscribe, e-mail:
For additional commands, e-mail:

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