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

Alan Woodward commented on LUCENE-8811:
---------------------------------------

Hi [~zabetak], the idea is to try and prevent runaway query execution; 
TermInSetQuery is implemented so that it can handle a very large number of 
terms efficiently, while the equivalent boolean disjunction would be very slow 
and use lots of memory.  So we primarily want to run this check on 
BooleanQuery, but we also want to handle nested booleans, booleans wrapped in 
other queries, etc, in which case a QueryVisitor makes most sense.

> I see that TermInSetQuery#visit for example already iterates through all 
> terms so if we don't need then we are just wasting CPU cycles without a very 
> good reason.

This should definitely be fixed! I think we probably want to change 
TermInSetQuery#visit to call consumeMatchingTerms() with a lazy runAutomaton 
implementation; the num clauses check visitor also needs to count 
consumeMatchingTerms calls.

> Add maximum clause count check to IndexSearcher rather than BooleanQuery
> ------------------------------------------------------------------------
>
>                 Key: LUCENE-8811
>                 URL: https://issues.apache.org/jira/browse/LUCENE-8811
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Adrien Grand
>            Assignee: Alan Woodward
>            Priority: Minor
>             Fix For: master (9.0)
>
>         Attachments: LUCENE-8811.patch, LUCENE-8811.patch, LUCENE-8811.patch, 
> LUCENE-8811.patch, LUCENE-8811.patch, LUCENE-8811.patch
>
>
> Currently we only check whether boolean queries have too many clauses. 
> However there are other ways that queries may have too many clauses, for 
> instance if you have boolean queries that have themselves inner boolean 
> queries.
> Could we use the new Query visitor API to move this check from BooleanQuery 
> to IndexSearcher in order to make this check more consistent across queries? 
> See for instance LUCENE-8810 where a rewrite rule caused the maximum clause 
> count to be hit even though the total number of leaf queries remained the 
> same.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to