[ 
https://issues.apache.org/jira/browse/LUCENE-6889?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14998882#comment-14998882
 ] 

Uwe Schindler edited comment on LUCENE-6889 at 11/10/15 4:44 PM:
-----------------------------------------------------------------

bq. Seeing as a FILTER is a non scoring MUST this just doesn't sound right. The 
FILTER could constrain the result set more than just the MUST alone

We were talking about a FILTER and a identical MUST clause on the base level 
without any additional brackets/bbols inside. In those cases the FILTER does 
not do more than the MUST clause already did.

bq. rewrite queries of the form {{+\*:\* #filter}} to a 
ConstantScoreQuery(filter)

This works, because that is the reason for this issue and was done exactly like 
that since Lucene 4.0 in FilteredQuery, which did exactly that: 
{{FilteredQuery(MatchAllDocs,Filter) => ConstantScoreQuery(Filter)}}. You just 
have to copy the boost of the matchall docs to the constant score query. Of 
course you have to make sure, you don't break coordination factors, which is 
not a problem for filters (they have no effect on coordination factor).


was (Author: thetaphi):
bq. Seeing as a FILTER is a non scoring MUST this just doesn't sound right. The 
FILTER could constrain the result set more than just the MUST alone

We were talking about a FILTER and a identical MUST clause on the base level 
without any additional brackets/bbols inside. In those cases the FILTER does 
not do more than the MUST clause already did.

bq. rewrite queries of the form {{+*:* #filter}} to a ConstantScoreQuery(filter)

This works, because that is the reason for this issue and was done exactly like 
that since Lucene 4.0 in FilteredQuery, which did exactly that: 
{{FilteredQuery(MatchAllDocs,Filter) => ConstantScoreQuery(Filter)}}. You just 
have to copy the boost of the matchall docs to the constant score query. Of 
course you have to make sure, you don't break coordination factors, which is 
not a problem for filters (they have no effect on coordination factor).

> BooleanQuery.rewrite could easily optimize some simple cases
> ------------------------------------------------------------
>
>                 Key: LUCENE-6889
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6889
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Adrien Grand
>            Priority: Minor
>
> Follow-up of SOLR-8251: APIs and user interfaces sometimes encourage to write 
> BooleanQuery instances that are not optimal, for instance a typical case that 
> happens often with Solr/Elasticsearch is to send a request that has a 
> MatchAllDocsQuery as a query and some filter, which could be executed more 
> efficiently by directly wrapping the filter into a ConstantScoreQuery.
> Here are some ideas of rewrite operations that BooleanQuery could perform:
>  - remove FILTER clauses when they are also a MUST clause
>  - rewrite queries of the form "+*:* #filter" to a ConstantScoreQuery(filter)
>  - rewrite to a MatchNoDocsQuery when a clause that is a MUST or FILTER 
> clause is also a MUST_NOT clause



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to