You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Michael McCandless (JIRA)" <ji...@apache.org> on 2015/03/08 23:48:38 UTC
[jira] [Commented] (LUCENE-6347) MultiFieldQueryParser doesnt catch
invalid syntax properly (due to user using regexpression syntax
unwittingly)
[ https://issues.apache.org/jira/browse/LUCENE-6347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14352322#comment-14352322 ]
Michael McCandless commented on LUCENE-6347:
--------------------------------------------
Hmm I tried to reproduce this on 4.10.x, and it would not repro. So I tried on 4.1.0 and it still won't repro. I just ran this javac and java command from lucene subdir of a 4.1.0 checkout:
{noformat}
mike@haswell:/l/410/lucene$ javac -cp build/core/lucene-core-4.1-SNAPSHOT.jar:build/queryparser/lucene-queryparser-4.1-SNAPSHOT.jar:test-framework/lib/junit-4.10.jar:build/analysis/common/lucene-analyzers-common-4.1-SNAPSHOT.jar LuceneRegExParseTest.java ; java -cp .:build/core/lucene-core-4.1-SNAPSHOT.jar:build/queryparser/lucene-queryparser-4.1-SNAPSHOT.jar:test-framework/lib/junit-4.10.jar:build/analysis/common/lucene-analyzers-common-4.1-SNAPSHOT.jar org.junit.runner.JUnitCore LuceneRegExParseTest
{noformat}
and I get this output:
{noformat}
JUnit version 4.10
.E
Time: 0.039
There was 1 failure:
1) testSearch411LuceneBugReport(LuceneRegExParseTest)
java.lang.AssertionError
at org.junit.Assert.fail(Assert.java:92)
at org.junit.Assert.assertTrue(Assert.java:43)
at org.junit.Assert.assertNotNull(Assert.java:526)
at org.junit.Assert.assertNotNull(Assert.java:537)
at LuceneRegExParseTest.testSearch411LuceneBugReport(LuceneRegExParseTest.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
{noformat}
Meaning no exception was hit...
> MultiFieldQueryParser doesnt catch invalid syntax properly (due to user using regexpression syntax unwittingly)
> ---------------------------------------------------------------------------------------------------------------
>
> Key: LUCENE-6347
> URL: https://issues.apache.org/jira/browse/LUCENE-6347
> Project: Lucene - Core
> Issue Type: Bug
> Components: core/queryparser
> Affects Versions: 4.1
> Reporter: Paul taylor
>
> MultiFieldQueryParser doesnt catch invalid syntax properly (due to user using regexpression syntax unwittingly)
> {code}
> import org.apache.lucene.analysis.standard.StandardAnalyzer;
> import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
> import org.apache.lucene.queryparser.classic.ParseException;
> import org.apache.lucene.queryparser.classic.QueryParser;
> import org.apache.lucene.util.Version;
> import org.junit.Test;
> import static org.junit.Assert.assertNotNull;
> import static org.junit.Assert.assertTrue;
> /**
> * Lucene tests
> */
> public class LuceneRegExParseTest
> {
> @Test
> public void testSearch411LuceneBugReport() throws Exception
> {
> Exception e = null;
> try
> {
> String[] fields = new String[2];
> fields[0] = "artist";
> fields[1] = "recording";
> QueryParser qp = new MultiFieldQueryParser(Version.LUCENE_41, fields, new StandardAnalyzer(Version.LUCENE_41));
> qp.parse("artist:pandora /reyli recording:yo/Alguien");
> }
> catch(Exception ex)
> {
> e=ex;
> }
> assertNotNull(e);
> assertTrue(e instanceof ParseException );
> }
> }
> {code}
> With assertions disabled this test fails as no exception is thrown.
> With assertions enabled we get
> {code}
> java.lang.AssertionError
> at org.apache.lucene.search.MultiTermQuery.<init>(MultiTermQuery.java:252)
> at org.apache.lucene.search.AutomatonQuery.<init>(AutomatonQuery.java:65)
> at org.apache.lucene.search.RegexpQuery.<init>(RegexpQuery.java:90)
> at org.apache.lucene.search.RegexpQuery.<init>(RegexpQuery.java:79)
> at org.apache.lucene.search.RegexpQuery.<init>(RegexpQuery.java:69)
> at org.apache.lucene.queryparser.classic.QueryParserBase.newRegexpQuery(QueryParserBase.java:790)
> at org.apache.lucene.queryparser.classic.QueryParserBase.getRegexpQuery(QueryParserBase.java:1005)
> at org.apache.lucene.queryparser.classic.QueryParserBase.handleBareTokenQuery(QueryParserBase.java:1075)
> at org.apache.lucene.queryparser.classic.QueryParser.Term(QueryParser.java:359)
> at org.apache.lucene.queryparser.classic.QueryParser.Clause(QueryParser.java:258)
> at org.apache.lucene.queryparser.classic.QueryParser.Query(QueryParser.java:213)
> at org.apache.lucene.queryparser.classic.QueryParser.TopLevelQuery(QueryParser.java:171)
> at org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryParserBase.java:120)
> at org.musicbrainz.search.servlet.LuceneRegExParseTest.testSearch411LuceneBugReport(LuceneRegExParseTest.java:30)
> but this should throw an exception without assertions enabled. Because no exception is thrown a search then faikls with the following stack trace
> java.lang.NullPointerException
> at java.util.TreeMap.getEntry(TreeMap.java:342)
> at java.util.TreeMap.get(TreeMap.java:273)
> at org.apache.lucene.codecs.perfield.PerFieldPostingsFormat$FieldsReader.terms(PerFieldPostingsFormat.java:215)
> at org.apache.lucene.search.TermCollectingRewrite.collectTerms(TermCollectingRewrite.java:58)
> at org.apache.lucene.search.ConstantScoreAutoRewrite.rewrite(ConstantScoreAutoRewrite.java:95)
> at org.apache.lucene.search.MultiTermQuery$ConstantScoreAutoRewrite.rewrite(MultiTermQuery.java:220)
> at org.apache.lucene.search.MultiTermQuery.rewrite(MultiTermQuery.java:286)
> at org.apache.lucene.search.BooleanQuery.rewrite(BooleanQuery.java:429)
> at org.apache.lucene.search.IndexSearcher.rewrite(IndexSearcher.java:616)
> at org.apache.lucene.search.IndexSearcher.createNormalizedWeight(IndexSearcher.java:663)
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:281)
> at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:269)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org