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:16:31 UTC

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

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x 0c43ae2b5 -> 59c5e6014


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/59c5e601
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/59c5e601
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/59c5e601

Branch: refs/heads/branch_6x
Commit: 59c5e6014bc8f2e3f89a269938145dc7da5e9019
Parents: 0c43ae2
Author: jbernste <jb...@apache.org>
Authored: Tue Jun 28 13:03:34 2016 -0400
Committer: jbernste <jb...@apache.org>
Committed: Tue Jun 28 13:11:19 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/59c5e601/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 112ceb9..f921696 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -54,6 +54,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/59c5e601/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);