You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jb...@apache.org on 2016/06/28 17:09:22 UTC

lucene-solr:master: SOLR-9254: GraphTermsQueryQParserPlugin throws NPE when field being search is not present in segment

Repository: lucene-solr
Updated Branches:
  refs/heads/master ab2348e3e -> 407080af5


SOLR-9254: GraphTermsQueryQParserPlugin throws NPE when field being search is not present in segment


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/407080af
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/407080af
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/407080af

Branch: refs/heads/master
Commit: 407080af5bc68c9eb11c05c587368a783ff78d0c
Parents: ab2348e
Author: jbernste <jb...@apache.org>
Authored: Tue Jun 28 13:03:34 2016 -0400
Committer: jbernste <jb...@apache.org>
Committed: Tue Jun 28 13:03:34 2016 -0400

----------------------------------------------------------------------
 solr/CHANGES.txt                                                | 4 ++++
 .../java/org/apache/solr/search/GraphTermsQParserPlugin.java    | 5 +++++
 2 files changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/407080af/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index ee8babe..7fc6f56 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -86,6 +86,10 @@ Bug Fixes
 
 * SOLR-8626: 404 error when clicking nodes in cloud graph view in angular UI. (janhoy, Trey Grainger via shalin)
 
+* SOLR-9254: GraphTermsQueryQParserPlugin throws NPE when field being search is not present in segment
+  (Joel Bernstein)
+
+
 Optimizations
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/407080af/solr/core/src/java/org/apache/solr/search/GraphTermsQParserPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/GraphTermsQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/GraphTermsQParserPlugin.java
index 664fa07..dfe411a 100644
--- a/solr/core/src/java/org/apache/solr/search/GraphTermsQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/GraphTermsQParserPlugin.java
@@ -40,9 +40,11 @@ import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Weight;
 import org.apache.lucene.util.ArrayUtil;
+import org.apache.lucene.util.BitDocIdSet;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.BytesRefBuilder;
 import org.apache.lucene.util.DocIdSetBuilder;
+import org.apache.lucene.util.FixedBitSet;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.schema.FieldType;
@@ -220,6 +222,9 @@ public class GraphTermsQParserPlugin extends QParserPlugin {
           final LeafReader reader = context.reader();
           final Fields fields = reader.fields();
           Terms terms = fields.terms(field);
+          if(terms == null) {
+            return new WeightOrDocIdSet(new BitDocIdSet(new FixedBitSet(reader.maxDoc()), 0));
+          }
           TermsEnum  termsEnum = terms.iterator();
           PostingsEnum docs = null;
           DocIdSetBuilder builder = new DocIdSetBuilder(reader.maxDoc(), terms);