iverase opened a new issue, #14756: URL: https://github.com/apache/lucene/issues/14756
I noticed that if I change a query from a PointRangeQuery to an IndexOrDocValuesQuery, then the change might make previous valid boolean queries to fail because IndexOrDocValuesQuery counts twice when computing `maxClauseCount. I think this is wrong as IndexOrDocValues is just providing lucene with the choice of two execution paths and should not count twice for that limit. This test proves the issue: ``` public void testIndexOrDocValues() throws IOException { Directory dir = newDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random(), dir); Document d = new Document(); d.add(new LongField("foo", 0L, LongField.Store.NO)); writer.addDocument(d); d = new Document(); d.add(new LongField("foo", Long.MAX_VALUE, LongField.Store.NO)); writer.addDocument(d); IndexReader reader = writer.getReader(); IndexSearcher searcher = newSearcher(reader); writer.close(); int maxClauseCount = IndexSearcher.getMaxClauseCount(); BooleanQuery.Builder qb = new BooleanQuery.Builder(); for (int i = 0; i < maxClauseCount; i++) { qb.add(LongPoint.newRangeQuery("foo", 0, i), BooleanClause.Occur.SHOULD); } // should not throw an exception, because it is below the limit searcher.rewrite(qb.build()); qb = new BooleanQuery.Builder(); for (int i = 0; i < maxClauseCount; i++) { qb.add(LongField.newRangeQuery("foo", 0, i), BooleanClause.Occur.SHOULD); } // should not throw an exception, because it is below the limit searcher.rewrite(qb.build()); } ``` It fails in the second rewrite with the exception: ``` org.apache.lucene.search.IndexSearcher$TooManyNestedClauses: Query contains too many nested clauses; maxClauseCount is set to 1024 at __randomizedtesting.SeedInfo.seed([1DBE2F81F126780A:AB3F95EEC9898FF7]:0) at org.apache.lucene.search.IndexSearcher$1.visitLeaf(IndexSearcher.java:905) at org.apache.lucene.document.SortedNumericDocValuesRangeQuery.visit(SortedNumericDocValuesRangeQuery.java:74) at org.apache.lucene.search.IndexOrDocValuesQuery.visit(IndexOrDocValuesQuery.java:134) at org.apache.lucene.search.BooleanQuery.visit(BooleanQuery.java:661) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org