SOLR-10836: igain, significantTerms, and tlogit assumed existing terms

This commit is contained in:
David Smiley 2017-06-09 23:39:23 -04:00
parent 566fcfce13
commit 5c781d5679
4 changed files with 13 additions and 11 deletions

View File

@ -350,6 +350,11 @@ Bug Fixes
* SOLR-10829: Fixed IndexSchema to enforce that uniqueKey can not be Points based for correctness (hossman)
* SOLR-10836: The query parsers igain, significantTerms, and tlogit (used by streaming expressions by
the same name) might throw a NullPointerException if the referenced field had no indexed data in some
shards. The fix included an optimization to use Solr's cached AtomicReader instead of re-calculating.
(David Smiley)
Optimizations
----------------------
* SOLR-10634: JSON Facet API: When a field/terms facet will retrieve all buckets (i.e. limit:-1)

View File

@ -23,7 +23,6 @@ import java.util.TreeSet;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.MultiFields;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.index.Terms;
@ -162,8 +161,8 @@ public class IGainTermsQParserPlugin extends QParserPlugin {
double pc = numPositiveDocs / numDocs;
double entropyC = binaryEntropy(pc);
Terms terms = MultiFields.getFields(searcher.getIndexReader()).terms(field);
TermsEnum termsEnum = terms.iterator();
Terms terms = ((SolrIndexSearcher)searcher).getSlowAtomicReader().terms(field);
TermsEnum termsEnum = terms == null ? TermsEnum.EMPTY : terms.iterator();
BytesRef term;
PostingsEnum postingsEnum = null;
while ((term = termsEnum.next()) != null) {

View File

@ -19,12 +19,11 @@ package org.apache.solr.search;
import java.io.IOException;
import java.util.TreeSet;
import java.util.List;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeSet;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.MultiFields;
import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
@ -146,8 +145,8 @@ public class SignificantTermsQParserPlugin extends QParserPlugin {
//TODO: Use a priority queue
TreeSet<TermWithScore> topTerms = new TreeSet<>();
Terms terms = MultiFields.getFields(searcher.getIndexReader()).terms(field);
TermsEnum termsEnum = terms.iterator();
Terms terms = ((SolrIndexSearcher)searcher).getSlowAtomicReader().terms(field);
TermsEnum termsEnum = terms == null ? TermsEnum.EMPTY : terms.iterator();
BytesRef term;
PostingsEnum postingsEnum = null;

View File

@ -26,7 +26,6 @@ import java.util.Map;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.MultiFields;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.index.Terms;
@ -173,8 +172,8 @@ public class TextLogisticRegressionQParserPlugin extends QParserPlugin {
public void finish() throws IOException {
Map<Integer, double[]> docVectors = new HashMap<>();
Terms terms = MultiFields.getFields(searcher.getIndexReader()).terms(trainingParams.feature);
TermsEnum termsEnum = terms.iterator();
Terms terms = ((SolrIndexSearcher)searcher).getSlowAtomicReader().terms(trainingParams.feature);
TermsEnum termsEnum = terms == null ? TermsEnum.EMPTY : terms.iterator();
PostingsEnum postingsEnum = null;
int termIndex = 0;
for (String termStr : trainingParams.terms) {