mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-22 22:27:47 -04:00
fix potiential NPE
This commit is contained in:
parent
c4428b12e1
commit
41f6aab388
2 changed files with 11 additions and 4 deletions
|
@ -81,8 +81,11 @@ public class DocIdSets {
|
|||
return set;
|
||||
}
|
||||
// TODO: should we use WAH8DocIdSet like Lucene?
|
||||
FixedBitSet fixedBitSet = new FixedBitSet(reader.maxDoc());
|
||||
it = set.iterator();
|
||||
if (it == null) {
|
||||
return DocIdSet.EMPTY;
|
||||
}
|
||||
FixedBitSet fixedBitSet = new FixedBitSet(reader.maxDoc());
|
||||
long cost = it.cost();
|
||||
fixedBitSet.or(it);
|
||||
return new BitDocIdSet(fixedBitSet, cost);
|
||||
|
|
|
@ -70,6 +70,7 @@ import static org.elasticsearch.index.query.QueryBuilders.constantScoreQuery;
|
|||
import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.factorFunction;
|
||||
import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.scriptFunction;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
/**
|
||||
|
@ -2005,7 +2006,6 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
|
||||
assertNoFailures(scrollResponse);
|
||||
assertThat(scrollResponse.getHits().totalHits(), equalTo(10l));
|
||||
|
||||
int scannedDocs = 0;
|
||||
do {
|
||||
scrollResponse = client()
|
||||
|
@ -2232,7 +2232,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
}
|
||||
|
||||
SearchResponse MinMaxQuery(String scoreType, int minChildren, int maxChildren, int cutoff) throws SearchPhaseExecutionException {
|
||||
return client()
|
||||
SearchResponse response = client()
|
||||
.prepareSearch("test")
|
||||
.setQuery(
|
||||
QueryBuilders
|
||||
|
@ -2244,15 +2244,19 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest {
|
|||
.add(FilterBuilders.termFilter("foo", "four"), factorFunction(1))).scoreType(scoreType)
|
||||
.minChildren(minChildren).maxChildren(maxChildren).setShortCircuitCutoff(cutoff))
|
||||
.addSort("_score", SortOrder.DESC).addSort("id", SortOrder.ASC).get();
|
||||
assertSearchResponse(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
SearchResponse MinMaxFilter( int minChildren, int maxChildren, int cutoff) throws SearchPhaseExecutionException {
|
||||
return client()
|
||||
SearchResponse response = client()
|
||||
.prepareSearch("test")
|
||||
.setQuery(
|
||||
QueryBuilders.constantScoreQuery(FilterBuilders.hasChildFilter("child", termFilter("foo", "two"))
|
||||
.minChildren(minChildren).maxChildren(maxChildren).setShortCircuitCutoff(cutoff)))
|
||||
.addSort("id", SortOrder.ASC).setTrackScores(true).get();
|
||||
assertSearchResponse(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue