You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Apurv Verma <ap...@bloomreach.com> on 2015/02/02 11:30:52 UTC

Lucene Boolean Query Minimization

Hey all,
 I have a large boolean query in lucene which can be minimized to a smaller
version with fewer clauses. Does Lucene automatically minimize complex
boolean queries to simpler versions before executing them?

If not, are there are predefined ways to do so?

-- 
Regards,
Apurv

AW: Lucene Boolean Query Minimization

Posted by Ralf Heyde <ra...@gmx.de>.
The question here is: is a 'smaller' boolean query consuming less ressources? 

Gruss, Ralf

Gesendet vom Mobiltelefon
‎
  Originalnachricht  
Von: Ralf Heyde
Gesendet: Montag, 2. Februar 2015 16:28
An: java-user@lucene.apache.org; java-user@lucene.apache.org
Antwort an: java-user@lucene.apache.org
Betreff: AW: Lucene Boolean Query Minimization

Just an idea: could it be optimized by boolean Algebra?

Gruss, Ralf

Gesendet vom Mobiltelefon
‎
  Originalnachricht  
Von: Uwe Schindler
Gesendet: Montag, 2. Februar 2015 16:25
An: java-user@lucene.apache.org
Antwort an: java-user@lucene.apache.org
Betreff: RE: Lucene Boolean Query Minimization

Hi,

You don't give an example of the type of Boolean query you want to "minimize". I have no idea "how" it could be optimized without that information. If a Boolean query contains only one clause, it is rewritten automatically to be the query of its single clause (with boosts multiplied). But if you have many Boolean clauses, how could those be optimized? If you have multiple term queries as clauses with identical terms, one could optimize that by merging those clauses and add their boosts, but this is not done automatically.

Uwe

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


> -----Original Message-----
> From: Apurv Verma [mailto:apurv@bloomreach.com]
> Sent: Monday, February 02, 2015 11:31 AM
> To: java-user@lucene.apache.org
> Subject: Lucene Boolean Query Minimization
> 
> Hey all,
> I have a large boolean query in lucene which can be minimized to a smaller
> version with fewer clauses. Does Lucene automatically minimize complex
> boolean queries to simpler versions before executing them?
> 
> If not, are there are predefined ways to do so?
> 
> --
> Regards,
> Apurv


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


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


RE: Lucene Boolean Query Minimization

Posted by Uwe Schindler <uw...@thetaphi.de>.
In general: BooleanQuery is a bad name, because it is not "just" Boolean algebra:
- There are also "Boosts" involved
- Also, the algebra consists of MUST, MUST_NOT and SHOULD. You cannot transform this easily to classical mathematical algebra :-)

See also: https://lucidworks.com/blog/why-not-and-or-and-not/

Uwe

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


> -----Original Message-----
> From: Ralf Heyde [mailto:ralf.heyde@gmx.de]
> Sent: Monday, February 02, 2015 4:28 PM
> To: java-user@lucene.apache.org; java-user@lucene.apache.org
> Subject: AW: Lucene Boolean Query Minimization
> 
> Just an idea: could it be optimized by boolean Algebra?
> 
> Gruss, Ralf
> 
> Gesendet vom Mobiltelefon
> ‎
>   Originalnachricht
> Von: Uwe Schindler
> Gesendet: Montag, 2. Februar 2015 16:25
> An: java-user@lucene.apache.org
> Antwort an: java-user@lucene.apache.org
> Betreff: RE: Lucene Boolean Query Minimization
> 
> Hi,
> 
> You don't give an example of the type of Boolean query you want to
> "minimize". I have no idea "how" it could be optimized without that
> information. If a Boolean query contains only one clause, it is rewritten
> automatically to be the query of its single clause (with boosts multiplied). But
> if you have many Boolean clauses, how could those be optimized? If you
> have multiple term queries as clauses with identical terms, one could
> optimize that by merging those clauses and add their boosts, but this is not
> done automatically.
> 
> Uwe
> 
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
> 
> 
> > -----Original Message-----
> > From: Apurv Verma [mailto:apurv@bloomreach.com]
> > Sent: Monday, February 02, 2015 11:31 AM
> > To: java-user@lucene.apache.org
> > Subject: Lucene Boolean Query Minimization
> >
> > Hey all,
> > I have a large boolean query in lucene which can be minimized to a
> > smaller version with fewer clauses. Does Lucene automatically minimize
> > complex boolean queries to simpler versions before executing them?
> >
> > If not, are there are predefined ways to do so?
> >
> > --
> > Regards,
> > Apurv
> 
> 
> ---------------------------------------------------------------------
> 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


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


AW: Lucene Boolean Query Minimization

Posted by Ralf Heyde <ra...@gmx.de>.
Just an idea: could it be optimized by boolean Algebra?

Gruss, Ralf

Gesendet vom Mobiltelefon
‎
  Originalnachricht  
Von: Uwe Schindler
Gesendet: Montag, 2. Februar 2015 16:25
An: java-user@lucene.apache.org
Antwort an: java-user@lucene.apache.org
Betreff: RE: Lucene Boolean Query Minimization

Hi,

You don't give an example of the type of Boolean query you want to "minimize". I have no idea "how" it could be optimized without that information. If a Boolean query contains only one clause, it is rewritten automatically to be the query of its single clause (with boosts multiplied). But if you have many Boolean clauses, how could those be optimized? If you have multiple term queries as clauses with identical terms, one could optimize that by merging those clauses and add their boosts, but this is not done automatically.

Uwe

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


> -----Original Message-----
> From: Apurv Verma [mailto:apurv@bloomreach.com]
> Sent: Monday, February 02, 2015 11:31 AM
> To: java-user@lucene.apache.org
> Subject: Lucene Boolean Query Minimization
> 
> Hey all,
> I have a large boolean query in lucene which can be minimized to a smaller
> version with fewer clauses. Does Lucene automatically minimize complex
> boolean queries to simpler versions before executing them?
> 
> If not, are there are predefined ways to do so?
> 
> --
> Regards,
> Apurv


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


RE: Lucene Boolean Query Minimization

Posted by Uwe Schindler <uw...@thetaphi.de>.
Hi,

You don't give an example of the type of Boolean query you want to "minimize". I have no idea "how" it could be optimized without that information. If a Boolean query contains only one clause, it is rewritten automatically to be the query of its single clause (with boosts multiplied). But if you have many Boolean clauses, how could those be optimized? If you have multiple term queries as clauses with identical terms, one could optimize that by merging those clauses and add their boosts, but this is not done automatically.

Uwe

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


> -----Original Message-----
> From: Apurv Verma [mailto:apurv@bloomreach.com]
> Sent: Monday, February 02, 2015 11:31 AM
> To: java-user@lucene.apache.org
> Subject: Lucene Boolean Query Minimization
> 
> Hey all,
>  I have a large boolean query in lucene which can be minimized to a smaller
> version with fewer clauses. Does Lucene automatically minimize complex
> boolean queries to simpler versions before executing them?
> 
> If not, are there are predefined ways to do so?
> 
> --
> Regards,
> Apurv


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