Marc created LUCENE-10651:
-----------------------------

             Summary: SimpleQueryParser stack overflow for large nested queries.
                 Key: LUCENE-10651
                 URL: https://issues.apache.org/jira/browse/LUCENE-10651
             Project: Lucene - Core
          Issue Type: Bug
    Affects Versions: 9.2, 8.10, 9.1, 9.3
            Reporter: Marc


The OpenSearch project received an issue [1] where stack overflow can occur for 
large nested boolean queries during rewrite.  In trying to reproduce this error 
I've also encountered SO during parsing where queries expand beyond the default 
1024 clause limit.  This unit test will fail with SO:
{code:java}
public void testSimpleQueryParserWithTooManyClauses() {
  StringBuilder queryString = new StringBuilder("foo");
  for (int i = 0; i < 1024; i++) {
    queryString.append(" | bar").append(i).append(" + baz");
  }
  expectThrows(IndexSearcher.TooManyClauses.class, () -> 
parse(queryString.toString()));
}
 {code}
I would expect this case to also fail with TooManyClauses, is my understanding 
correct?  If so, I've attempted a fix [2] that during parsing increments a 
counter whenever a clause is added.

 [1] [https://github.com/opensearch-project/OpenSearch/issues/3760]

 [2] 
[https://github.com/mch2/lucene/commit/6a558f17f448b92ae4cf8c43e0b759ff7425acdf]

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to