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

This commit is contained in:
jbernste 2016-06-28 13:03:34 -04:00
parent ab2348e3ef
commit 407080af5b
2 changed files with 9 additions and 0 deletions

View File

@ -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
----------------------

View File

@ -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);