lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <...@thetaphi.de>
Subject RE: Boolean OR does not work as described
Date Tue, 03 Jan 2012 16:31:08 GMT
Hi Mike,

if you want to mix and/or in one query, always use parenthesis. The operator precedence is
strange with the default query parser. In contrib there is another one (called PrecedenceQueryParser)
that can handle this but is incompatible with existing queries. The parser in contrib on the
other hand also has other problems, which are all caused by the way how Lucene handles BooleanQuery
internally.

If you print the parsed query using Query.toString() you can see the "normalized" query in
standard Lucene syntax. Lucene does not know AND/OR, it only knows query clauses that are
SHOULD (=optional), MUST or MUST_NOT. The query "vorgklasse:au AND schluessel:13????? OR schluessel:23?????"
will be parsed like:

MUST: vorgklasse:au
MUST: schluessel:13?????
SHOULD: schluessel:23?????

Which would be in standard syntax: "+vorgklasse:au +schluessel:13????? schluessel:23?????"
(first two are MUST clauses, third is should). If you read this query using MUST/SHOULD you
will understand what happens: This means the first 2 terms MUST be in the result, the third
MIGHT be in the result. So it's not an union, it's something more complex :-)

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: 1983-01-06@gmx.net [mailto:1983-01-06@gmx.net]
> Sent: Tuesday, January 03, 2012 4:41 PM
> To: java-user@lucene.apache.org
> Subject: Boolean OR does not work as described
> 
> Hi folks,
> 
> I have a query result problem I do not understand. The documentation for
> Lucene 3.2 query syntax says the following about boolean OR queries: "The OR
> operator links two terms and finds a matching document if either of the terms
> exist in a document. This is equivalent to a union using sets."
> 
> I have performed several queries on my index and the output does not reflect
> the description. I always get the first-wins-set instead of a united set.
> 
> These are my separate test results:
> 1. schluessel:23????? => 286 documents
> 2. vorgklasse:au AND schluessel:13????? => 2532 documents
> 
> If I do:
> vorgklasse:au AND schluessel:13????? OR schluessel:23?????
> It should unite both sets and output them. I still get 2532 documents back.
> Exactly those from the second query.
> 
> Am I not supposed to get 2532 + 286 = 2818? This is what I expect as result set.
> Am I missing something here? If I group the query like this (vorgklasse:au AND
> sch
> luessel:13?????) OR schluessel:23????? I do get the expected result. But both
> queries should be equivalent.
> 
> Thanks,
> 
> Mike
> 
> PS: search output is avaible as CSV at request
> --
> NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!
> 
> Jetzt informieren: http://www.gmx.net/de/go/freephone
> 
> 
> --
> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie
> mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
> 
> 
> --
> NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!
> 
> Jetzt informieren: http://www.gmx.net/de/go/freephone
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org


---------------------------------------------------------------------
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