benchaplin opened a new pull request, #13323:
URL: https://github.com/apache/lucene/pull/13323

   ### Description
   
   I've added some unit tests to protect/display the QueryParser's ability to 
parse brackets in range query terms when in quotes.
   
   [This issue](https://github.com/apache/lucene/issues/13234) raised a 
question about the QueryParser's ability to handle brackets in a range query's 
terms, even when escaped, for example:
   
   ```java
   queryParser.parse( "[ a\\[i\\] TO b\\[i\\] ]" );
   
   /* 
   org.apache.lucene.queryparser.classic.ParseException: Cannot parse '[a\[i\] 
TO b\[i\]]': Encountered " "]" "] "" at line 1, column 6.
   Was expecting:
       "TO" ...
    */
   ```
   
   You can get around this exception by wrapping each range query term in 
quotes:
   ```java
   queryParser.parse( "[\"a[i]\" TO \"b[i]\"]" );
   ```
   
   This is because of [this JavaCC grammar 
rule](https://github.com/apache/lucene/blob/9af3ef8952597ead37a5a9ce5373ed3bbd40238e/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.jj#L345).
 `<RANGE_GOOP>` cannot handle a closing bracket, even an escaped one, while 
`<RANGE_QUOTED>` can.
   
   I've added some unit tests to protect this functionality.
   
   ---
   
   Any thoughts on whether `queryParser.parse( "[ a\\[i\\] TO b\\[i\\] ]" );` 
should work? I did play around with updating the grammar, it should be possible 
but I need to think more about how it might break backwards compatibility.
   
   
   
   


-- 
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

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

Reply via email to