benwtrent opened a new issue, #12069: URL: https://github.com/apache/lucene/issues/12069
### Description When there is deeply nested Boolean clauses, the rewrite time can be exceptionally long in the non-scoring case. On my machine, this test takes 3+ seconds to run. I suspect its this change: https://github.com/apache/lucene/pull/672 I manually reverted that change, and the rewrite time dropped to 3ms. If I changed the top level Boolean clause to `MUST` from `FILTER` (to enable scoring) the rewrite time is ~3ms. A depth of 20 isn't unheard of, though it is a complicated query. I expect rewrite to take SOME time, but 3+ seconds seems like a bug to me. Unscientific unit test to confirm performance impact: ```java public void testDeeplyNestedBooleanRewrite() throws IOException { IndexSearcher searcher = newSearcher(new MultiReader()); Directory dir = newDirectory(); (new RandomIndexWriter(random(), dir)).close(); IndexReader r = DirectoryReader.open(dir); Supplier<TermQuery> randomTermQuery = () -> new TermQuery( new Term( TestUtil.randomSimpleString(random()), TestUtil.randomSimpleString(random()))); int depth = 20; BooleanQuery deepBuilder = new BooleanQuery.Builder() .setMinimumNumberShouldMatch(1) .add(randomTermQuery.get(), BooleanClause.Occur.MUST) .add(randomTermQuery.get(), BooleanClause.Occur.MUST) .build(); for (int i = 0; i < depth; i++) { BooleanQuery.Builder bq = new BooleanQuery.Builder() .setMinimumNumberShouldMatch(1) .add(randomTermQuery.get(), BooleanClause.Occur.MUST) .add(randomTermQuery.get(), BooleanClause.Occur.MUST) .add(deepBuilder, BooleanClause.Occur.MUST); deepBuilder = bq.build(); } BooleanQuery bq = new BooleanQuery.Builder() .setMinimumNumberShouldMatch(1) .add(deepBuilder, Occur.FILTER) .build(); long start = System.currentTimeMillis(); searcher.rewrite(bq); long finish = System.currentTimeMillis(); r.close(); dir.close(); // Always fail to print assertFalse(Long.toString(finish - start), finish > start); } ``` ### Version and environment details Lucene version 9.3+ -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
