Handle core search refactoring

Original commit: elastic/x-pack-elasticsearch@fb512063ca
This commit is contained in:
Nik Everett 2016-04-12 15:19:21 -04:00
parent 61fdd0ac3c
commit 120e13148b
3 changed files with 15 additions and 15 deletions

View File

@ -196,7 +196,7 @@ public class SearchTransformIT extends ESIntegTestCase {
assertThat(result.type(), is(SearchTransform.TYPE)); assertThat(result.type(), is(SearchTransform.TYPE));
assertThat(result.status(), is(Transform.Result.Status.FAILURE)); assertThat(result.status(), is(Transform.Result.Status.FAILURE));
assertThat(result.reason(), notNullValue()); assertThat(result.reason(), notNullValue());
assertThat(result.reason(), containsString("No query registered for [_unknown_query_]")); assertThat(result.reason(), containsString("no [query] registered for [_unknown_query_]"));
// extract the base64 encoded query from the template script, path is: query -> wrapper -> query // extract the base64 encoded query from the template script, path is: query -> wrapper -> query
String jsonQuery = result.executedRequest().template().getScript(); String jsonQuery = result.executedRequest().template().getScript();

View File

@ -136,9 +136,9 @@ public class WatcherUtilsTests extends ESTestCase {
builder = WatcherUtils.writeSearchRequest(expectedRequest, builder, ToXContent.EMPTY_PARAMS); builder = WatcherUtils.writeSearchRequest(expectedRequest, builder, ToXContent.EMPTY_PARAMS);
XContentParser parser = XContentHelper.createParser(builder.bytes()); XContentParser parser = XContentHelper.createParser(builder.bytes());
assertThat(parser.nextToken(), equalTo(XContentParser.Token.START_OBJECT)); assertThat(parser.nextToken(), equalTo(XContentParser.Token.START_OBJECT));
QueryParser<MatchAllQueryBuilder> termQueryParser = MatchAllQueryBuilder::fromXContent; IndicesQueriesRegistry registry = new IndicesQueriesRegistry();
IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, QueryParser<MatchAllQueryBuilder> queryParser = MatchAllQueryBuilder::fromXContent;
singletonMap(MatchAllQueryBuilder.NAME, new Tuple<>(MatchAllQueryBuilder.QUERY_NAME_FIELD, termQueryParser))); registry.register(queryParser, MatchAllQueryBuilder.QUERY_NAME_FIELD);
QueryParseContext context = new QueryParseContext(registry); QueryParseContext context = new QueryParseContext(registry);
context.reset(parser); context.reset(parser);
SearchRequest result = WatcherUtils.readSearchRequest(parser, ExecutableSearchInput.DEFAULT_SEARCH_TYPE, context, null, null); SearchRequest result = WatcherUtils.readSearchRequest(parser, ExecutableSearchInput.DEFAULT_SEARCH_TYPE, context, null, null);
@ -226,9 +226,9 @@ public class WatcherUtilsTests extends ESTestCase {
XContentParser parser = XContentHelper.createParser(builder.bytes()); XContentParser parser = XContentHelper.createParser(builder.bytes());
assertThat(parser.nextToken(), equalTo(XContentParser.Token.START_OBJECT)); assertThat(parser.nextToken(), equalTo(XContentParser.Token.START_OBJECT));
QueryParser<MatchAllQueryBuilder> termQueryParser = MatchAllQueryBuilder::fromXContent; IndicesQueriesRegistry registry = new IndicesQueriesRegistry();
IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, QueryParser<MatchAllQueryBuilder> queryParser = MatchAllQueryBuilder::fromXContent;
singletonMap(MatchAllQueryBuilder.NAME, new Tuple<>(MatchAllQueryBuilder.QUERY_NAME_FIELD, termQueryParser))); registry.register(queryParser, MatchAllQueryBuilder.QUERY_NAME_FIELD);
QueryParseContext context = new QueryParseContext(registry); QueryParseContext context = new QueryParseContext(registry);
context.reset(parser); context.reset(parser);
SearchRequest result = WatcherUtils.readSearchRequest(parser, ExecutableSearchInput.DEFAULT_SEARCH_TYPE, context, null, null); SearchRequest result = WatcherUtils.readSearchRequest(parser, ExecutableSearchInput.DEFAULT_SEARCH_TYPE, context, null, null);

View File

@ -353,9 +353,9 @@ public class WatchTests extends ESTestCase {
Map<String, InputFactory> parsers = new HashMap<>(); Map<String, InputFactory> parsers = new HashMap<>();
switch (input.type()) { switch (input.type()) {
case SearchInput.TYPE: case SearchInput.TYPE:
QueryParser<MatchAllQueryBuilder> termQueryParser = MatchAllQueryBuilder::fromXContent; IndicesQueriesRegistry queryRegistry = new IndicesQueriesRegistry();
IndicesQueriesRegistry queryRegistry = new IndicesQueriesRegistry(Settings.EMPTY, singletonMap( QueryParser<MatchAllQueryBuilder> queryParser = MatchAllQueryBuilder::fromXContent;
MatchAllQueryBuilder.NAME, new Tuple<>(MatchAllQueryBuilder.QUERY_NAME_FIELD, termQueryParser))); queryRegistry.register(queryParser, MatchAllQueryBuilder.QUERY_NAME_FIELD);
parsers.put(SearchInput.TYPE, new SearchInputFactory(settings, client, queryRegistry, null, null)); parsers.put(SearchInput.TYPE, new SearchInputFactory(settings, client, queryRegistry, null, null));
return new InputRegistry(parsers); return new InputRegistry(parsers);
default: default:
@ -421,9 +421,9 @@ public class WatchTests extends ESTestCase {
} }
private TransformRegistry transformRegistry() { private TransformRegistry transformRegistry() {
QueryParser<MatchAllQueryBuilder> termQueryParser = MatchAllQueryBuilder::fromXContent; IndicesQueriesRegistry queryRegistry = new IndicesQueriesRegistry();
IndicesQueriesRegistry queryRegistry = new IndicesQueriesRegistry(Settings.EMPTY, QueryParser<MatchAllQueryBuilder> queryParser = MatchAllQueryBuilder::fromXContent;
singletonMap(MatchAllQueryBuilder.NAME, new Tuple<>(MatchAllQueryBuilder.QUERY_NAME_FIELD, termQueryParser))); queryRegistry.register(queryParser, MatchAllQueryBuilder.QUERY_NAME_FIELD);
Map<String, TransformFactory> factories = new HashMap<>(); Map<String, TransformFactory> factories = new HashMap<>();
ChainTransformFactory parser = new ChainTransformFactory(); ChainTransformFactory parser = new ChainTransformFactory();
factories.put(ChainTransform.TYPE, parser); factories.put(ChainTransform.TYPE, parser);