You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by er...@apache.org on 2017/12/27 20:10:59 UTC
lucene-solr:branch_7x: SOLR-11555: If the query terms reduce to
nothing, filter(clause) produces an NPE whereas fq=clause does not
Repository: lucene-solr
Updated Branches:
refs/heads/branch_7x 89344ea4c -> a78db4b25
SOLR-11555: If the query terms reduce to nothing, filter(clause) produces an NPE whereas fq=clause does not
(cherry picked from commit 05ab5e1)
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/a78db4b2
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a78db4b2
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a78db4b2
Branch: refs/heads/branch_7x
Commit: a78db4b259551464ba252e54d84e95d6c456b461
Parents: 89344ea
Author: Erick Erickson <er...@apache.org>
Authored: Wed Dec 27 12:05:31 2017 -0800
Committer: Erick Erickson <er...@apache.org>
Committed: Wed Dec 27 12:06:18 2017 -0800
----------------------------------------------------------------------
solr/CHANGES.txt | 3 +++
.../java/org/apache/solr/query/FilterQuery.java | 5 +++++
.../apache/solr/search/TestSolrQueryParser.java | 20 ++++++++++++++++++++
3 files changed, 28 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a78db4b2/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index c211724..832d8dd 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -48,6 +48,9 @@ Bug Fixes
* SOLR-11783: Rename core in solr standalone mode is not persisted (Erick Erickson)
+* SOLR-11555: If the query terms reduce to nothing, filter(clause) produces an NPE whereas
+ fq=clause does not (Erick Erickson)
+
Optimizations
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a78db4b2/solr/core/src/java/org/apache/solr/query/FilterQuery.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/query/FilterQuery.java b/solr/core/src/java/org/apache/solr/query/FilterQuery.java
index 785ab5c..a5a7ab0 100644
--- a/solr/core/src/java/org/apache/solr/query/FilterQuery.java
+++ b/solr/core/src/java/org/apache/solr/query/FilterQuery.java
@@ -22,6 +22,7 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.BoostQuery;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Weight;
import org.apache.solr.search.DocSet;
@@ -33,6 +34,10 @@ public class FilterQuery extends ExtendedQueryBase {
protected final Query q;
public FilterQuery(Query q) {
+ if (q == null) {
+ this.q = new MatchNoDocsQuery();
+ return;
+ }
this.q = q;
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a78db4b2/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java b/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java
index 4bf4cc5..9008595 100644
--- a/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java
+++ b/solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.java
@@ -497,6 +497,26 @@ public class TestSolrQueryParser extends SolrTestCaseJ4 {
, "/response/docs/[0]/score==10.0"
);
+ assertU(adoc("id", "40", "wdf_nocase", "just some text, don't want NPE"));
+ assertU(commit());
+
+ // See SOLR-11555. If wdff removes all the characters, an NPE occurs.
+ // try q and fq
+ assertJQ(req("q", "filter(wdf_nocase:&)", "fl", "id", "debug", "query")
+ , "/response/numFound==0"
+ );
+ assertJQ(req("fq", "filter(wdf_nocase:.,)", "fl", "id", "debug", "query")
+ , "/response/numFound==0"
+ );
+
+ // Insure the same behavior as with bare clause, just not filter
+ assertJQ(req("q", "wdf_nocase:&", "fl", "id", "debug", "query")
+ , "/response/numFound==0"
+ );
+ assertJQ(req("fq", "wdf_nocase:.,", "fl", "id", "debug", "query")
+ , "/response/numFound==0"
+ );
+
}