Adapt to changes in core ES (elastic/elasticsearch#17417)
Original commit: elastic/x-pack-elasticsearch@2df6d5b27e
This commit is contained in:
parent
e66a6871c0
commit
e6bce6b36e
|
@ -5,6 +5,15 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.graph.rest.action;
|
package org.elasticsearch.graph.rest.action;
|
||||||
|
|
||||||
|
import static org.elasticsearch.graph.action.GraphExploreAction.INSTANCE;
|
||||||
|
import static org.elasticsearch.rest.RestRequest.Method.GET;
|
||||||
|
import static org.elasticsearch.rest.RestRequest.Method.POST;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.action.support.IndicesOptions;
|
import org.elasticsearch.action.support.IndicesOptions;
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
|
@ -17,10 +26,10 @@ import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.graph.action.GraphExploreRequest;
|
import org.elasticsearch.graph.action.GraphExploreRequest;
|
||||||
|
import org.elasticsearch.graph.action.GraphExploreRequest.TermBoost;
|
||||||
import org.elasticsearch.graph.action.GraphExploreResponse;
|
import org.elasticsearch.graph.action.GraphExploreResponse;
|
||||||
import org.elasticsearch.graph.action.Hop;
|
import org.elasticsearch.graph.action.Hop;
|
||||||
import org.elasticsearch.graph.action.VertexRequest;
|
import org.elasticsearch.graph.action.VertexRequest;
|
||||||
import org.elasticsearch.graph.action.GraphExploreRequest.TermBoost;
|
|
||||||
import org.elasticsearch.index.query.QueryParseContext;
|
import org.elasticsearch.index.query.QueryParseContext;
|
||||||
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
|
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
|
||||||
import org.elasticsearch.rest.BaseRestHandler;
|
import org.elasticsearch.rest.BaseRestHandler;
|
||||||
|
@ -30,15 +39,6 @@ import org.elasticsearch.rest.RestRequest;
|
||||||
import org.elasticsearch.rest.action.support.RestActions;
|
import org.elasticsearch.rest.action.support.RestActions;
|
||||||
import org.elasticsearch.rest.action.support.RestToXContentListener;
|
import org.elasticsearch.rest.action.support.RestToXContentListener;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.elasticsearch.graph.action.GraphExploreAction.INSTANCE;
|
|
||||||
import static org.elasticsearch.rest.RestRequest.Method.GET;
|
|
||||||
import static org.elasticsearch.rest.RestRequest.Method.POST;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see GraphExploreRequest
|
* @see GraphExploreRequest
|
||||||
*/
|
*/
|
||||||
|
@ -85,14 +85,12 @@ public class RestGraphAction extends BaseRestHandler {
|
||||||
if (!RestActions.hasBodyContent(request)) {
|
if (!RestActions.hasBodyContent(request)) {
|
||||||
throw new ElasticsearchParseException("Body missing for graph request");
|
throw new ElasticsearchParseException("Body missing for graph request");
|
||||||
}
|
}
|
||||||
QueryParseContext context = new QueryParseContext(indicesQueriesRegistry);
|
|
||||||
BytesReference qBytes = RestActions.getRestContent(request);
|
BytesReference qBytes = RestActions.getRestContent(request);
|
||||||
|
|
||||||
Hop currentHop = graphRequest.createNextHop(null);
|
Hop currentHop = graphRequest.createNextHop(null);
|
||||||
|
|
||||||
try(XContentParser parser = XContentFactory.xContent(qBytes).createParser(qBytes)) {
|
try(XContentParser parser = XContentFactory.xContent(qBytes).createParser(qBytes)) {
|
||||||
|
QueryParseContext context = new QueryParseContext(indicesQueriesRegistry, parser, parseFieldMatcher);
|
||||||
context.parser(parser);
|
|
||||||
|
|
||||||
XContentParser.Token token = parser.nextToken();
|
XContentParser.Token token = parser.nextToken();
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.watcher.input.search;
|
package org.elasticsearch.watcher.input.search;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.elasticsearch.common.ParseFieldMatcher;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.logging.Loggers;
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -18,8 +21,6 @@ import org.elasticsearch.watcher.input.InputFactory;
|
||||||
import org.elasticsearch.watcher.input.simple.ExecutableSimpleInput;
|
import org.elasticsearch.watcher.input.simple.ExecutableSimpleInput;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -30,11 +31,13 @@ public class SearchInputFactory extends InputFactory<SearchInput, SearchInput.Re
|
||||||
private final IndicesQueriesRegistry queryRegistry;
|
private final IndicesQueriesRegistry queryRegistry;
|
||||||
private final AggregatorParsers aggParsers;
|
private final AggregatorParsers aggParsers;
|
||||||
private final Suggesters suggesters;
|
private final Suggesters suggesters;
|
||||||
|
private final ParseFieldMatcher parseFieldMatcher;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SearchInputFactory(Settings settings, WatcherClientProxy client, IndicesQueriesRegistry queryRegistry,
|
public SearchInputFactory(Settings settings, WatcherClientProxy client, IndicesQueriesRegistry queryRegistry,
|
||||||
AggregatorParsers aggParsers, Suggesters suggesters) {
|
AggregatorParsers aggParsers, Suggesters suggesters) {
|
||||||
super(Loggers.getLogger(ExecutableSimpleInput.class, settings));
|
super(Loggers.getLogger(ExecutableSimpleInput.class, settings));
|
||||||
|
this.parseFieldMatcher = new ParseFieldMatcher(settings);
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.queryRegistry = queryRegistry;
|
this.queryRegistry = queryRegistry;
|
||||||
this.aggParsers = aggParsers;
|
this.aggParsers = aggParsers;
|
||||||
|
@ -49,8 +52,7 @@ public class SearchInputFactory extends InputFactory<SearchInput, SearchInput.Re
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SearchInput parseInput(String watchId, XContentParser parser) throws IOException {
|
public SearchInput parseInput(String watchId, XContentParser parser) throws IOException {
|
||||||
QueryParseContext context = new QueryParseContext(queryRegistry);
|
QueryParseContext context = new QueryParseContext(queryRegistry, parser, parseFieldMatcher);
|
||||||
context.reset(parser);
|
|
||||||
return SearchInput.parse(watchId, parser, context, aggParsers, suggesters);
|
return SearchInput.parse(watchId, parser, context, aggParsers, suggesters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.watcher.transform.search;
|
package org.elasticsearch.watcher.transform.search;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.elasticsearch.common.ParseFieldMatcher;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.logging.Loggers;
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -13,12 +16,10 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.index.query.QueryParseContext;
|
import org.elasticsearch.index.query.QueryParseContext;
|
||||||
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
|
import org.elasticsearch.indices.query.IndicesQueriesRegistry;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorParsers;
|
import org.elasticsearch.search.aggregations.AggregatorParsers;
|
||||||
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
|
||||||
import org.elasticsearch.search.suggest.Suggesters;
|
import org.elasticsearch.search.suggest.Suggesters;
|
||||||
|
import org.elasticsearch.watcher.support.init.proxy.WatcherClientProxy;
|
||||||
import org.elasticsearch.watcher.transform.TransformFactory;
|
import org.elasticsearch.watcher.transform.TransformFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -29,12 +30,14 @@ public class SearchTransformFactory extends TransformFactory<SearchTransform, Se
|
||||||
private final IndicesQueriesRegistry queryRegistry;
|
private final IndicesQueriesRegistry queryRegistry;
|
||||||
private final AggregatorParsers aggParsers;
|
private final AggregatorParsers aggParsers;
|
||||||
private final Suggesters suggesters;
|
private final Suggesters suggesters;
|
||||||
|
private final ParseFieldMatcher parseFieldMatcher;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SearchTransformFactory(Settings settings, WatcherClientProxy client, IndicesQueriesRegistry queryRegistry,
|
public SearchTransformFactory(Settings settings, WatcherClientProxy client, IndicesQueriesRegistry queryRegistry,
|
||||||
AggregatorParsers aggParsers, Suggesters suggesters) {
|
AggregatorParsers aggParsers, Suggesters suggesters) {
|
||||||
super(Loggers.getLogger(ExecutableSearchTransform.class, settings));
|
super(Loggers.getLogger(ExecutableSearchTransform.class, settings));
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
this.parseFieldMatcher = new ParseFieldMatcher(settings);
|
||||||
this.queryRegistry = queryRegistry;
|
this.queryRegistry = queryRegistry;
|
||||||
this.aggParsers = aggParsers;
|
this.aggParsers = aggParsers;
|
||||||
this.suggesters = suggesters;
|
this.suggesters = suggesters;
|
||||||
|
@ -48,8 +51,7 @@ public class SearchTransformFactory extends TransformFactory<SearchTransform, Se
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SearchTransform parseTransform(String watchId, XContentParser parser) throws IOException {
|
public SearchTransform parseTransform(String watchId, XContentParser parser) throws IOException {
|
||||||
QueryParseContext context = new QueryParseContext(queryRegistry);
|
QueryParseContext context = new QueryParseContext(queryRegistry, parser, parseFieldMatcher);
|
||||||
context.reset(parser);
|
|
||||||
return SearchTransform.parse(watchId, parser, context, aggParsers, suggesters);
|
return SearchTransform.parse(watchId, parser, context, aggParsers, suggesters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,17 @@
|
||||||
package org.elasticsearch.watcher.support;
|
package org.elasticsearch.watcher.support;
|
||||||
|
|
||||||
|
|
||||||
|
import static java.util.Collections.singletonMap;
|
||||||
|
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||||
|
import static org.elasticsearch.watcher.support.WatcherDateTimeUtils.formatDate;
|
||||||
|
import static org.elasticsearch.watcher.support.WatcherUtils.DEFAULT_INDICES_OPTIONS;
|
||||||
|
import static org.elasticsearch.watcher.support.WatcherUtils.flattenModel;
|
||||||
|
import static org.elasticsearch.watcher.test.WatcherTestUtils.getRandomSupportedSearchType;
|
||||||
|
import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
|
||||||
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
import static org.hamcrest.Matchers.hasEntry;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -15,10 +26,9 @@ import java.util.Map;
|
||||||
import org.elasticsearch.action.search.SearchRequest;
|
import org.elasticsearch.action.search.SearchRequest;
|
||||||
import org.elasticsearch.action.search.SearchType;
|
import org.elasticsearch.action.search.SearchType;
|
||||||
import org.elasticsearch.action.support.IndicesOptions;
|
import org.elasticsearch.action.support.IndicesOptions;
|
||||||
|
import org.elasticsearch.common.ParseFieldMatcher;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.collect.Tuple;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
@ -39,18 +49,6 @@ import org.elasticsearch.watcher.support.clock.SystemClock;
|
||||||
import org.elasticsearch.watcher.support.text.TextTemplate;
|
import org.elasticsearch.watcher.support.text.TextTemplate;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
import static java.util.Collections.singletonMap;
|
|
||||||
|
|
||||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
|
||||||
import static org.elasticsearch.watcher.support.WatcherDateTimeUtils.formatDate;
|
|
||||||
import static org.elasticsearch.watcher.support.WatcherUtils.DEFAULT_INDICES_OPTIONS;
|
|
||||||
import static org.elasticsearch.watcher.support.WatcherUtils.flattenModel;
|
|
||||||
import static org.elasticsearch.watcher.test.WatcherTestUtils.getRandomSupportedSearchType;
|
|
||||||
import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
|
||||||
import static org.hamcrest.Matchers.hasEntry;
|
|
||||||
import static org.hamcrest.Matchers.is;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -139,8 +137,7 @@ public class WatcherUtilsTests extends ESTestCase {
|
||||||
IndicesQueriesRegistry registry = new IndicesQueriesRegistry();
|
IndicesQueriesRegistry registry = new IndicesQueriesRegistry();
|
||||||
QueryParser<MatchAllQueryBuilder> queryParser = MatchAllQueryBuilder::fromXContent;
|
QueryParser<MatchAllQueryBuilder> queryParser = MatchAllQueryBuilder::fromXContent;
|
||||||
registry.register(queryParser, MatchAllQueryBuilder.QUERY_NAME_FIELD);
|
registry.register(queryParser, MatchAllQueryBuilder.QUERY_NAME_FIELD);
|
||||||
QueryParseContext context = new QueryParseContext(registry);
|
QueryParseContext context = new QueryParseContext(registry, parser, ParseFieldMatcher.STRICT);
|
||||||
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);
|
||||||
|
|
||||||
assertThat(result.indices(), arrayContainingInAnyOrder(expectedRequest.indices()));
|
assertThat(result.indices(), arrayContainingInAnyOrder(expectedRequest.indices()));
|
||||||
|
@ -229,8 +226,7 @@ public class WatcherUtilsTests extends ESTestCase {
|
||||||
IndicesQueriesRegistry registry = new IndicesQueriesRegistry();
|
IndicesQueriesRegistry registry = new IndicesQueriesRegistry();
|
||||||
QueryParser<MatchAllQueryBuilder> queryParser = MatchAllQueryBuilder::fromXContent;
|
QueryParser<MatchAllQueryBuilder> queryParser = MatchAllQueryBuilder::fromXContent;
|
||||||
registry.register(queryParser, MatchAllQueryBuilder.QUERY_NAME_FIELD);
|
registry.register(queryParser, MatchAllQueryBuilder.QUERY_NAME_FIELD);
|
||||||
QueryParseContext context = new QueryParseContext(registry);
|
QueryParseContext context = new QueryParseContext(registry, parser, ParseFieldMatcher.STRICT);
|
||||||
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);
|
||||||
|
|
||||||
assertThat(result.indices(), arrayContainingInAnyOrder(indices));
|
assertThat(result.indices(), arrayContainingInAnyOrder(indices));
|
||||||
|
|
Loading…
Reference in New Issue