|
@@ -19,7 +19,6 @@
|
|
package org.elasticsearch.search;
|
|
package org.elasticsearch.search;
|
|
|
|
|
|
import com.carrotsearch.hppc.IntArrayList;
|
|
import com.carrotsearch.hppc.IntArrayList;
|
|
-
|
|
|
|
import org.apache.lucene.search.Query;
|
|
import org.apache.lucene.search.Query;
|
|
import org.apache.lucene.store.AlreadyClosedException;
|
|
import org.apache.lucene.store.AlreadyClosedException;
|
|
import org.elasticsearch.action.ActionListener;
|
|
import org.elasticsearch.action.ActionListener;
|
|
@@ -59,6 +58,8 @@ import org.elasticsearch.script.MockScriptEngine;
|
|
import org.elasticsearch.script.MockScriptPlugin;
|
|
import org.elasticsearch.script.MockScriptPlugin;
|
|
import org.elasticsearch.script.Script;
|
|
import org.elasticsearch.script.Script;
|
|
import org.elasticsearch.script.ScriptType;
|
|
import org.elasticsearch.script.ScriptType;
|
|
|
|
+import org.elasticsearch.search.aggregations.InternalAggregation;
|
|
|
|
+import org.elasticsearch.search.aggregations.MultiBucketConsumerService;
|
|
import org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder;
|
|
import org.elasticsearch.search.aggregations.bucket.global.GlobalAggregationBuilder;
|
|
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
|
|
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
|
|
import org.elasticsearch.search.aggregations.support.ValueType;
|
|
import org.elasticsearch.search.aggregations.support.ValueType;
|
|
@@ -155,7 +156,7 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
|
return Settings.builder().put("search.default_search_timeout", "5s").build();
|
|
return Settings.builder().put("search.default_search_timeout", "5s").build();
|
|
}
|
|
}
|
|
|
|
|
|
- public void testClearOnClose() throws ExecutionException, InterruptedException {
|
|
|
|
|
|
+ public void testClearOnClose() {
|
|
createIndex("index");
|
|
createIndex("index");
|
|
client().prepareIndex("index", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
|
|
client().prepareIndex("index", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
|
|
SearchResponse searchResponse = client().prepareSearch("index").setSize(1).setScroll("1m").get();
|
|
SearchResponse searchResponse = client().prepareSearch("index").setSize(1).setScroll("1m").get();
|
|
@@ -167,7 +168,7 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
|
assertEquals(0, service.getActiveContexts());
|
|
assertEquals(0, service.getActiveContexts());
|
|
}
|
|
}
|
|
|
|
|
|
- public void testClearOnStop() throws ExecutionException, InterruptedException {
|
|
|
|
|
|
+ public void testClearOnStop() {
|
|
createIndex("index");
|
|
createIndex("index");
|
|
client().prepareIndex("index", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
|
|
client().prepareIndex("index", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
|
|
SearchResponse searchResponse = client().prepareSearch("index").setSize(1).setScroll("1m").get();
|
|
SearchResponse searchResponse = client().prepareSearch("index").setSize(1).setScroll("1m").get();
|
|
@@ -179,7 +180,7 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
|
assertEquals(0, service.getActiveContexts());
|
|
assertEquals(0, service.getActiveContexts());
|
|
}
|
|
}
|
|
|
|
|
|
- public void testClearIndexDelete() throws ExecutionException, InterruptedException {
|
|
|
|
|
|
+ public void testClearIndexDelete() {
|
|
createIndex("index");
|
|
createIndex("index");
|
|
client().prepareIndex("index", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
|
|
client().prepareIndex("index", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
|
|
SearchResponse searchResponse = client().prepareSearch("index").setSize(1).setScroll("1m").get();
|
|
SearchResponse searchResponse = client().prepareSearch("index").setSize(1).setScroll("1m").get();
|
|
@@ -208,7 +209,7 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
|
assertEquals(activeRefs, indexShard.store().refCount());
|
|
assertEquals(activeRefs, indexShard.store().refCount());
|
|
}
|
|
}
|
|
|
|
|
|
- public void testSearchWhileIndexDeleted() throws IOException, InterruptedException {
|
|
|
|
|
|
+ public void testSearchWhileIndexDeleted() throws InterruptedException {
|
|
createIndex("index");
|
|
createIndex("index");
|
|
client().prepareIndex("index", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
|
|
client().prepareIndex("index", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
|
|
|
|
|
|
@@ -443,15 +444,15 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- protected void doWriteTo(StreamOutput out) throws IOException {
|
|
|
|
|
|
+ protected void doWriteTo(StreamOutput out) {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- protected void doXContent(XContentBuilder builder, Params params) throws IOException {
|
|
|
|
|
|
+ protected void doXContent(XContentBuilder builder, Params params) {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- protected Query doToQuery(QueryShardContext context) throws IOException {
|
|
|
|
|
|
+ protected Query doToQuery(QueryShardContext context) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -501,7 +502,6 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
|
assertFalse(service.canMatch(new ShardSearchLocalRequest(indexShard.shardId(), 1, SearchType.QUERY_THEN_FETCH,
|
|
assertFalse(service.canMatch(new ShardSearchLocalRequest(indexShard.shardId(), 1, SearchType.QUERY_THEN_FETCH,
|
|
new SearchSourceBuilder().query(new MatchNoneQueryBuilder()), Strings.EMPTY_ARRAY, false,
|
|
new SearchSourceBuilder().query(new MatchNoneQueryBuilder()), Strings.EMPTY_ARRAY, false,
|
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, allowPartialSearchResults, null, null)));
|
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, allowPartialSearchResults, null, null)));
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public void testCanRewriteToMatchNone() {
|
|
public void testCanRewriteToMatchNone() {
|
|
@@ -519,7 +519,6 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
|
.suggest(new SuggestBuilder())));
|
|
.suggest(new SuggestBuilder())));
|
|
assertFalse(SearchService.canRewriteToMatchNone(new SearchSourceBuilder().query(new TermQueryBuilder("foo", "bar"))
|
|
assertFalse(SearchService.canRewriteToMatchNone(new SearchSourceBuilder().query(new TermQueryBuilder("foo", "bar"))
|
|
.suggest(new SuggestBuilder())));
|
|
.suggest(new SuggestBuilder())));
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public void testSetSearchThrottled() {
|
|
public void testSetSearchThrottled() {
|
|
@@ -568,4 +567,17 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
|
assertHitCount(client().prepareSearch().get(), 0L);
|
|
assertHitCount(client().prepareSearch().get(), 0L);
|
|
assertHitCount(client().prepareSearch().setIndicesOptions(IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED).get(), 1L);
|
|
assertHitCount(client().prepareSearch().setIndicesOptions(IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED).get(), 1L);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public void testCreateReduceContext() {
|
|
|
|
+ final SearchService service = getInstanceFromNode(SearchService.class);
|
|
|
|
+ {
|
|
|
|
+ InternalAggregation.ReduceContext reduceContext = service.createReduceContext(true);
|
|
|
|
+ expectThrows(MultiBucketConsumerService.TooManyBucketsException.class,
|
|
|
|
+ () -> reduceContext.consumeBucketsAndMaybeBreak(MultiBucketConsumerService.DEFAULT_MAX_BUCKETS + 1));
|
|
|
|
+ }
|
|
|
|
+ {
|
|
|
|
+ InternalAggregation.ReduceContext reduceContext = service.createReduceContext(false);
|
|
|
|
+ reduceContext.consumeBucketsAndMaybeBreak(MultiBucketConsumerService.DEFAULT_MAX_BUCKETS + 1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|