mirror of https://github.com/apache/lucene.git
fix NPE on empty index
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1493381 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8c6a36003c
commit
a415009d08
|
@ -122,11 +122,11 @@ class DrillSidewaysQuery extends Query {
|
|||
}
|
||||
lastField = field;
|
||||
}
|
||||
dims[dim].docsEnums = new DocsEnum[drillDownTerms[dim].length];
|
||||
if (termsEnum == null) {
|
||||
nullCount++;
|
||||
continue;
|
||||
}
|
||||
dims[dim].docsEnums = new DocsEnum[drillDownTerms[dim].length];
|
||||
for(int i=0;i<drillDownTerms[dim].length;i++) {
|
||||
if (termsEnum.seekExact(drillDownTerms[dim][i].bytes(), false)) {
|
||||
DocsEnum docsEnum = termsEnum.docs(null, null);
|
||||
|
@ -138,7 +138,7 @@ class DrillSidewaysQuery extends Query {
|
|||
}
|
||||
}
|
||||
|
||||
if (nullCount > 1) {
|
||||
if (nullCount > 1 || (nullCount == 1 && dims.length == 1)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,11 +80,9 @@ class DrillSidewaysScorer extends Scorer {
|
|||
// Position all scorers to their first matching doc:
|
||||
baseScorer.nextDoc();
|
||||
for(DocsEnumsAndFreq dim : dims) {
|
||||
if (dim.docsEnums != null) {
|
||||
for (DocsEnum docsEnum : dim.docsEnums) {
|
||||
if (docsEnum != null) {
|
||||
docsEnum.nextDoc();
|
||||
}
|
||||
for (DocsEnum docsEnum : dim.docsEnums) {
|
||||
if (docsEnum != null) {
|
||||
docsEnum.nextDoc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,11 +95,9 @@ class DrillSidewaysScorer extends Scorer {
|
|||
for(int dim=0;dim<numDims;dim++) {
|
||||
docsEnums[dim] = dims[dim].docsEnums;
|
||||
sidewaysCollectors[dim] = dims[dim].sidewaysCollector;
|
||||
if (dims[dim].docsEnums != null) {
|
||||
for (DocsEnum de : dims[dim].docsEnums) {
|
||||
if (de != null) {
|
||||
drillDownCost += de.cost();
|
||||
}
|
||||
for (DocsEnum de : dims[dim].docsEnums) {
|
||||
if (de != null) {
|
||||
drillDownCost += de.cost();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1175,6 +1175,5 @@ public class TestDrillSideways extends FacetTestCase {
|
|||
|
||||
IOUtils.close(searcher.getIndexReader(), taxoReader, dir, taxoDir);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue