You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2017/06/10 03:39:30 UTC
lucene-solr:master: SOLR-10836: igain, significantTerms,
and tlogit assumed existing terms
Repository: lucene-solr
Updated Branches:
refs/heads/master 566fcfce1 -> 5c781d567
SOLR-10836: igain, significantTerms, and tlogit assumed existing terms
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/5c781d56
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/5c781d56
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/5c781d56
Branch: refs/heads/master
Commit: 5c781d5679716dc46a28015c03ef9bcae824e58c
Parents: 566fcfc
Author: David Smiley <ds...@apache.org>
Authored: Fri Jun 9 23:39:23 2017 -0400
Committer: David Smiley <ds...@apache.org>
Committed: Fri Jun 9 23:39:23 2017 -0400
----------------------------------------------------------------------
solr/CHANGES.txt | 5 +++++
.../org/apache/solr/search/IGainTermsQParserPlugin.java | 5 ++---
.../apache/solr/search/SignificantTermsQParserPlugin.java | 9 ++++-----
.../solr/search/TextLogisticRegressionQParserPlugin.java | 5 ++---
4 files changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5c781d56/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d99a075..039a2c4 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -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)
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5c781d56/solr/core/src/java/org/apache/solr/search/IGainTermsQParserPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/IGainTermsQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/IGainTermsQParserPlugin.java
index bccbe06..053f50f 100644
--- a/solr/core/src/java/org/apache/solr/search/IGainTermsQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/IGainTermsQParserPlugin.java
@@ -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) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5c781d56/solr/core/src/java/org/apache/solr/search/SignificantTermsQParserPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/SignificantTermsQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/SignificantTermsQParserPlugin.java
index 9b9a46b..8346316 100644
--- a/solr/core/src/java/org/apache/solr/search/SignificantTermsQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/SignificantTermsQParserPlugin.java
@@ -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;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5c781d56/solr/core/src/java/org/apache/solr/search/TextLogisticRegressionQParserPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/TextLogisticRegressionQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/TextLogisticRegressionQParserPlugin.java
index c1b8906..842f746 100644
--- a/solr/core/src/java/org/apache/solr/search/TextLogisticRegressionQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/TextLogisticRegressionQParserPlugin.java
@@ -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) {