summaryrefslogtreecommitdiff
path: root/core/src/test/java/org/elasticsearch/search/SearchServiceTests.java
diff options
context:
space:
mode:
authorNik Everett <nik9000@gmail.com>2016-07-11 21:16:52 -0400
committerNik Everett <nik9000@gmail.com>2016-07-20 12:33:51 -0400
commit3a82c613e43ebfaa010e5cf5e79cc54cee2d9468 (patch)
tree27a3595109e0c6e21c6cd04f69a3dcb8effd3894 /core/src/test/java/org/elasticsearch/search/SearchServiceTests.java
parent2cf94d2d8a420813619fd1aeb6f5744f8c094b05 (diff)
Migrate query registration from push to pull
Remove `ParseField` constants used for names where there are no deprecated names and just use the `String` version of the registration method instead. This is step 2 in cleaning up the plugin interface for extending search time actions. Aggregations are next. This is breaking for plugins because those that register a new query should now implement `SearchPlugin` rather than `onModule(SearchModule)`.
Diffstat (limited to 'core/src/test/java/org/elasticsearch/search/SearchServiceTests.java')
-rw-r--r--core/src/test/java/org/elasticsearch/search/SearchServiceTests.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/core/src/test/java/org/elasticsearch/search/SearchServiceTests.java b/core/src/test/java/org/elasticsearch/search/SearchServiceTests.java
index 1c63ac7b62..fba71499cc 100644
--- a/core/src/test/java/org/elasticsearch/search/SearchServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/search/SearchServiceTests.java
@@ -22,7 +22,6 @@ package org.elasticsearch.search;
import org.apache.lucene.search.Query;
import org.elasticsearch.action.search.SearchPhaseExecutionException;
import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.XContentBuilder;
@@ -34,12 +33,15 @@ import org.elasticsearch.index.query.QueryShardContext;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.plugins.Plugin;
+import org.elasticsearch.plugins.SearchPlugin;
import org.elasticsearch.test.ESSingleNodeTestCase;
import java.io.IOException;
import java.util.Collection;
+import java.util.List;
import java.util.concurrent.ExecutionException;
+import static java.util.Collections.singletonList;
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.is;
@@ -110,12 +112,12 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
assertEquals(activeRefs, indexShard.store().refCount());
}
- public static class FailOnRewriteQueryPlugin extends Plugin {
-
- public void onModule(SearchModule module) {
- module.registerQuery(FailOnRewriteQueryBuilder::new, parseContext -> {
+ public static class FailOnRewriteQueryPlugin extends Plugin implements SearchPlugin {
+ @Override
+ public List<QuerySpec<?>> getQueries() {
+ return singletonList(new QuerySpec<>("fail_on_rewrite_query", FailOnRewriteQueryBuilder::new, parseContext -> {
throw new UnsupportedOperationException("No query parser for this plugin");
- }, new ParseField("fail_on_rewrite_query"));
+ }));
}
}