You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Steve Rowe (JIRA)" <ji...@apache.org> on 2017/12/14 19:16:03 UTC
[jira] [Commented] (SOLR-11761) Query parsing with comments fail in
org.apache.solr.parser.QueryParser
[ https://issues.apache.org/jira/browse/SOLR-11761?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16291390#comment-16291390 ]
Steve Rowe commented on SOLR-11761:
-----------------------------------
Full repro code on master:
{code:java|title=TestSolrQueryParser.java}
@Test public void testCommentsAfterSyntaxError() throws Exception {
SolrQueryRequest req = req();
QParserPlugin qParserPlugin = req.getCore().getQueryPlugin("lucene");
QParser qParser = qParserPlugin.createParser(null, null, null, req);
SolrQueryParser parser = new SolrQueryParser(qParser, "text");
expectThrows(SyntaxError.class, () -> parser.parse("/*"));
parser.parse("/* comment */ term");
}
{code}
produces:
{noformat}
org.apache.solr.parser.ParseException: Encountered "<EOF>" at line 1, column 18.
Was expecting one of:
<NOT> ...
"+" ...
"-" ...
<BAREOPER> ...
"(" ...
"*" ...
<QUOTED> ...
<TERM> ...
<PREFIXTERM> ...
<WILDTERM> ...
<REGEXPTERM> ...
"[" ...
"{" ...
<LPARAMS> ...
"filter(" ...
<NUMBER> ...
<TERM> ...
at org.apache.solr.parser.QueryParser.generateParseException(QueryParser.java:885)
at org.apache.solr.parser.QueryParser.jj_consume_token(QueryParser.java:767)
at org.apache.solr.parser.QueryParser.Query(QueryParser.java:167)
at org.apache.solr.parser.QueryParser.TopLevelQuery(QueryParser.java:131)
at org.apache.solr.parser.SolrQueryParserBase.parse(SolrQueryParserBase.java:254)
... 40 more
{noformat}
AFAICT because of the way QParsers work, SolrQueryParser instances are never required to parse more than one query. AFAICT there are no tests attempting that. Nevertheless I can think of no good reason for a parser (SolrQueryParser or any other) to hold onto state from previous queries like this; we should fix it.
> Query parsing with comments fail in org.apache.solr.parser.QueryParser
> ----------------------------------------------------------------------
>
> Key: SOLR-11761
> URL: https://issues.apache.org/jira/browse/SOLR-11761
> Project: Solr
> Issue Type: Bug
> Security Level: Public(Default Security Level. Issues are Public)
> Affects Versions: 6.2.1, 6.6.2
> Environment: Java 1.8
> Reproduced issue on org.apache.solr:solr-core:6.2.1 and 6.6.2
> Reporter: Andreas Presthammer
>
> Repro:
> org.apache.solr.parser.QueryParser queryParser = ...
> queryParser.parse("/* foo */ bar"); // works fine
> queryParser.parse("/*"); // fails with SyntaxError, which is correct.
> queryParser.parse("/* foo */ bar"); // Fails with SyntaxError. This is the bug
> queryParser.parse("bar"); // works fine
> queryParser.parse("/* foo */ bar"); // Still failing with SyntaxError
> The last parse call will continue to fail for expressions containing comments. Only way to work around that I've found it to create a new instance of QueryParser.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org