X-Plugin changes due to the changes in the Aggregations Java API
Original commit: elastic/x-pack-elasticsearch@b983d0a00f
This commit is contained in:
parent
ec76d3bce0
commit
197b8fe56f
|
@ -170,7 +170,7 @@ public class IndexActionIntegrationTests extends AbstractWatcherIntegrationTestC
|
||||||
.source(searchSource()
|
.source(searchSource()
|
||||||
.aggregation(dateHistogram("trend")
|
.aggregation(dateHistogram("trend")
|
||||||
.field("timestamp")
|
.field("timestamp")
|
||||||
.interval(DateHistogramInterval.DAY)))))
|
.dateHistogramInterval(DateHistogramInterval.DAY)))))
|
||||||
.addAction("index-buckets",
|
.addAction("index-buckets",
|
||||||
|
|
||||||
// this transform takes the bucket list and assigns it to `_doc`
|
// this transform takes the bucket list and assigns it to `_doc`
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("my-index")
|
SearchResponse response = client().prepareSearch("my-index")
|
||||||
.addAggregation(AggregationBuilders.dateHistogram("rate").field("_timestamp")
|
.addAggregation(AggregationBuilders.dateHistogram("rate").field("_timestamp")
|
||||||
.interval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC))
|
.dateHistogramInterval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
ExecutableScriptCondition condition = new ExecutableScriptCondition(
|
ExecutableScriptCondition condition = new ExecutableScriptCondition(
|
||||||
|
@ -85,9 +85,8 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa
|
||||||
client().prepareIndex("my-index", "my-type").setTimestamp("2005-01-01T00:40").setSource("{}").get();
|
client().prepareIndex("my-index", "my-type").setTimestamp("2005-01-01T00:40").setSource("{}").get();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
response = client().prepareSearch("my-index")
|
response = client().prepareSearch("my-index").addAggregation(AggregationBuilders.dateHistogram("rate").field("_timestamp")
|
||||||
.addAggregation(AggregationBuilders.dateHistogram("rate").field("_timestamp").interval(DateHistogramInterval.HOUR)
|
.dateHistogramInterval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC))
|
||||||
.order(Histogram.Order.COUNT_DESC))
|
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||||
|
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.messy.tests;
|
||||||
import org.elasticsearch.action.indexedscripts.put.PutIndexedScriptRequest;
|
import org.elasticsearch.action.indexedscripts.put.PutIndexedScriptRequest;
|
||||||
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.common.collect.HppcMaps;
|
|
||||||
import org.elasticsearch.common.io.Streams;
|
import org.elasticsearch.common.io.Streams;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
|
@ -282,7 +281,7 @@ public class SearchInputTests extends ESIntegTestCase {
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
|
|
||||||
IndicesQueriesRegistry indicesQueryRegistry = internalCluster().getInstance(IndicesQueriesRegistry.class);
|
IndicesQueriesRegistry indicesQueryRegistry = internalCluster().getInstance(IndicesQueriesRegistry.class);
|
||||||
SearchInputFactory factory = new SearchInputFactory(Settings.EMPTY, ClientProxy.of(client()), indicesQueryRegistry);
|
SearchInputFactory factory = new SearchInputFactory(Settings.EMPTY, ClientProxy.of(client()), indicesQueryRegistry, null);
|
||||||
|
|
||||||
SearchInput searchInput = factory.parseInput("_id", parser);
|
SearchInput searchInput = factory.parseInput("_id", parser);
|
||||||
assertEquals(SearchInput.TYPE, searchInput.type());
|
assertEquals(SearchInput.TYPE, searchInput.type());
|
||||||
|
|
|
@ -319,7 +319,8 @@ public class SearchTransformTests extends ESIntegTestCase {
|
||||||
|
|
||||||
IndicesQueriesRegistry indicesQueryRegistry = internalCluster().getInstance(IndicesQueriesRegistry.class);
|
IndicesQueriesRegistry indicesQueryRegistry = internalCluster().getInstance(IndicesQueriesRegistry.class);
|
||||||
SearchTransformFactory transformFactory = new SearchTransformFactory(Settings.EMPTY, ClientProxy.of(client()),
|
SearchTransformFactory transformFactory = new SearchTransformFactory(Settings.EMPTY, ClientProxy.of(client()),
|
||||||
indicesQueryRegistry);
|
indicesQueryRegistry,
|
||||||
|
null);
|
||||||
ExecutableSearchTransform executable = transformFactory.parseExecutable("_id", parser);
|
ExecutableSearchTransform executable = transformFactory.parseExecutable("_id", parser);
|
||||||
|
|
||||||
assertThat(executable, notNullValue());
|
assertThat(executable, notNullValue());
|
||||||
|
|
|
@ -347,7 +347,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("test")
|
SearchResponse response = client().prepareSearch("test")
|
||||||
.setTypes("type1")
|
.setTypes("type1")
|
||||||
.addAggregation(AggregationBuilders.children("children").childType("type2")
|
.addAggregation(AggregationBuilders.children("children", "type2")
|
||||||
.subAggregation(AggregationBuilders.terms("field3").field("field3")))
|
.subAggregation(AggregationBuilders.terms("field3").field("field3")))
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
|
@ -362,7 +362,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
|
||||||
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
|
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
|
||||||
.prepareSearch("test")
|
.prepareSearch("test")
|
||||||
.setTypes("type1")
|
.setTypes("type1")
|
||||||
.addAggregation(AggregationBuilders.children("children").childType("type2")
|
.addAggregation(AggregationBuilders.children("children", "type2")
|
||||||
.subAggregation(AggregationBuilders.terms("field3").field("field3")))
|
.subAggregation(AggregationBuilders.terms("field3").field("field3")))
|
||||||
.get();
|
.get();
|
||||||
assertHitCount(response, 1);
|
assertHitCount(response, 1);
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.index.query.QueryParseContext;
|
import org.elasticsearch.index.query.QueryParseContext;
|
||||||
|
import org.elasticsearch.search.aggregations.AggregatorParsers;
|
||||||
import org.elasticsearch.watcher.input.Input;
|
import org.elasticsearch.watcher.input.Input;
|
||||||
import org.elasticsearch.watcher.support.SearchRequestEquivalence;
|
import org.elasticsearch.watcher.support.SearchRequestEquivalence;
|
||||||
import org.elasticsearch.watcher.support.WatcherDateTimeUtils;
|
import org.elasticsearch.watcher.support.WatcherDateTimeUtils;
|
||||||
|
@ -110,7 +111,8 @@ public class SearchInput implements Input {
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SearchInput parse(String watchId, XContentParser parser, QueryParseContext context) throws IOException {
|
public static SearchInput parse(String watchId, XContentParser parser, QueryParseContext context, AggregatorParsers aggParsers)
|
||||||
|
throws IOException {
|
||||||
SearchRequest request = null;
|
SearchRequest request = null;
|
||||||
Set<String> extract = null;
|
Set<String> extract = null;
|
||||||
TimeValue timeout = null;
|
TimeValue timeout = null;
|
||||||
|
@ -123,7 +125,7 @@ public class SearchInput implements Input {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.REQUEST)) {
|
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.REQUEST)) {
|
||||||
try {
|
try {
|
||||||
request = WatcherUtils.readSearchRequest(parser, ExecutableSearchInput.DEFAULT_SEARCH_TYPE, context);
|
request = WatcherUtils.readSearchRequest(parser, ExecutableSearchInput.DEFAULT_SEARCH_TYPE, context, aggParsers);
|
||||||
} catch (ElasticsearchParseException srpe) {
|
} catch (ElasticsearchParseException srpe) {
|
||||||
throw new ElasticsearchParseException("could not parse [{}] input for watch [{}]. failed to parse [{}]", srpe, TYPE,
|
throw new ElasticsearchParseException("could not parse [{}] input for watch [{}]. failed to parse [{}]", srpe, TYPE,
|
||||||
watchId, currentFieldName);
|
watchId, currentFieldName);
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
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.watcher.input.InputFactory;
|
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.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
||||||
|
@ -26,12 +27,14 @@ public class SearchInputFactory extends InputFactory<SearchInput, SearchInput.Re
|
||||||
private final ClientProxy client;
|
private final ClientProxy client;
|
||||||
private final TimeValue defaultTimeout;
|
private final TimeValue defaultTimeout;
|
||||||
private IndicesQueriesRegistry queryRegistry;
|
private IndicesQueriesRegistry queryRegistry;
|
||||||
|
private AggregatorParsers aggParsers;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SearchInputFactory(Settings settings, ClientProxy client, IndicesQueriesRegistry queryRegistry) {
|
public SearchInputFactory(Settings settings, ClientProxy client, IndicesQueriesRegistry queryRegistry, AggregatorParsers aggParsers) {
|
||||||
super(Loggers.getLogger(ExecutableSimpleInput.class, settings));
|
super(Loggers.getLogger(ExecutableSimpleInput.class, settings));
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.queryRegistry = queryRegistry;
|
this.queryRegistry = queryRegistry;
|
||||||
|
this.aggParsers = aggParsers;
|
||||||
this.defaultTimeout = settings.getAsTime("watcher.input.search.default_timeout", null);
|
this.defaultTimeout = settings.getAsTime("watcher.input.search.default_timeout", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +47,7 @@ public class SearchInputFactory extends InputFactory<SearchInput, SearchInput.Re
|
||||||
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);
|
||||||
context.reset(parser);
|
context.reset(parser);
|
||||||
return SearchInput.parse(watchId, parser, context);
|
return SearchInput.parse(watchId, parser, context, aggParsers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.index.query.QueryParseContext;
|
import org.elasticsearch.index.query.QueryParseContext;
|
||||||
import org.elasticsearch.script.ScriptService.ScriptType;
|
import org.elasticsearch.script.ScriptService.ScriptType;
|
||||||
import org.elasticsearch.script.Template;
|
import org.elasticsearch.script.Template;
|
||||||
|
import org.elasticsearch.search.aggregations.AggregatorParsers;
|
||||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||||
import org.elasticsearch.watcher.execution.WatchExecutionContext;
|
import org.elasticsearch.watcher.execution.WatchExecutionContext;
|
||||||
import org.elasticsearch.watcher.watch.Payload;
|
import org.elasticsearch.watcher.watch.Payload;
|
||||||
|
@ -99,7 +100,8 @@ public final class WatcherUtils {
|
||||||
/**
|
/**
|
||||||
* Reads a new search request instance for the specified parser.
|
* Reads a new search request instance for the specified parser.
|
||||||
*/
|
*/
|
||||||
public static SearchRequest readSearchRequest(XContentParser parser, SearchType searchType, QueryParseContext context)
|
public static SearchRequest readSearchRequest(XContentParser parser, SearchType searchType, QueryParseContext context,
|
||||||
|
AggregatorParsers aggParsers)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
IndicesOptions indicesOptions = DEFAULT_INDICES_OPTIONS;
|
IndicesOptions indicesOptions = DEFAULT_INDICES_OPTIONS;
|
||||||
SearchRequest searchRequest = new SearchRequest();
|
SearchRequest searchRequest = new SearchRequest();
|
||||||
|
@ -110,7 +112,7 @@ public final class WatcherUtils {
|
||||||
if (token == XContentParser.Token.FIELD_NAME) {
|
if (token == XContentParser.Token.FIELD_NAME) {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, BODY_FIELD)) {
|
if (ParseFieldMatcher.STRICT.match(currentFieldName, BODY_FIELD)) {
|
||||||
searchRequest.source(SearchSourceBuilder.parseSearchSource(parser, context));
|
searchRequest.source(SearchSourceBuilder.parseSearchSource(parser, context, aggParsers));
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||||
if (ParseFieldMatcher.STRICT.match(currentFieldName, INDICES_FIELD)) {
|
if (ParseFieldMatcher.STRICT.match(currentFieldName, INDICES_FIELD)) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.index.query.QueryParseContext;
|
import org.elasticsearch.index.query.QueryParseContext;
|
||||||
|
import org.elasticsearch.search.aggregations.AggregatorParsers;
|
||||||
import org.elasticsearch.watcher.support.SearchRequestEquivalence;
|
import org.elasticsearch.watcher.support.SearchRequestEquivalence;
|
||||||
import org.elasticsearch.watcher.support.WatcherDateTimeUtils;
|
import org.elasticsearch.watcher.support.WatcherDateTimeUtils;
|
||||||
import org.elasticsearch.watcher.support.WatcherUtils;
|
import org.elasticsearch.watcher.support.WatcherUtils;
|
||||||
|
@ -92,7 +93,8 @@ public class SearchTransform implements Transform {
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SearchTransform parse(String watchId, XContentParser parser, QueryParseContext context) throws IOException {
|
public static SearchTransform parse(String watchId, XContentParser parser, QueryParseContext context, AggregatorParsers aggParsers)
|
||||||
|
throws IOException {
|
||||||
SearchRequest request = null;
|
SearchRequest request = null;
|
||||||
TimeValue timeout = null;
|
TimeValue timeout = null;
|
||||||
DateTimeZone dynamicNameTimeZone = null;
|
DateTimeZone dynamicNameTimeZone = null;
|
||||||
|
@ -104,7 +106,7 @@ public class SearchTransform implements Transform {
|
||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.REQUEST)) {
|
} else if (ParseFieldMatcher.STRICT.match(currentFieldName, Field.REQUEST)) {
|
||||||
try {
|
try {
|
||||||
request = WatcherUtils.readSearchRequest(parser, ExecutableSearchTransform.DEFAULT_SEARCH_TYPE, context);
|
request = WatcherUtils.readSearchRequest(parser, ExecutableSearchTransform.DEFAULT_SEARCH_TYPE, context, aggParsers);
|
||||||
} catch (ElasticsearchParseException srpe) {
|
} catch (ElasticsearchParseException srpe) {
|
||||||
throw new ElasticsearchParseException("could not parse [{}] transform for watch [{}]. failed to parse [{}]", srpe,
|
throw new ElasticsearchParseException("could not parse [{}] transform for watch [{}]. failed to parse [{}]", srpe,
|
||||||
TYPE, watchId, currentFieldName);
|
TYPE, watchId, currentFieldName);
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
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.watcher.support.init.proxy.ClientProxy;
|
import org.elasticsearch.watcher.support.init.proxy.ClientProxy;
|
||||||
import org.elasticsearch.watcher.transform.TransformFactory;
|
import org.elasticsearch.watcher.transform.TransformFactory;
|
||||||
|
|
||||||
|
@ -25,12 +26,15 @@ public class SearchTransformFactory extends TransformFactory<SearchTransform, Se
|
||||||
protected final ClientProxy client;
|
protected final ClientProxy client;
|
||||||
private final TimeValue defaultTimeout;
|
private final TimeValue defaultTimeout;
|
||||||
private IndicesQueriesRegistry queryRegistry;
|
private IndicesQueriesRegistry queryRegistry;
|
||||||
|
private AggregatorParsers aggParsers;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SearchTransformFactory(Settings settings, ClientProxy client, IndicesQueriesRegistry queryRegistry) {
|
public SearchTransformFactory(Settings settings, ClientProxy client, IndicesQueriesRegistry queryRegistry,
|
||||||
|
AggregatorParsers aggParsers) {
|
||||||
super(Loggers.getLogger(ExecutableSearchTransform.class, settings));
|
super(Loggers.getLogger(ExecutableSearchTransform.class, settings));
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.queryRegistry = queryRegistry;
|
this.queryRegistry = queryRegistry;
|
||||||
|
this.aggParsers = aggParsers;
|
||||||
this.defaultTimeout = settings.getAsTime("watcher.transform.search.default_timeout", null);
|
this.defaultTimeout = settings.getAsTime("watcher.transform.search.default_timeout", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +47,7 @@ public class SearchTransformFactory extends TransformFactory<SearchTransform, Se
|
||||||
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);
|
||||||
context.reset(parser);
|
context.reset(parser);
|
||||||
return SearchTransform.parse(watchId, parser, context);
|
return SearchTransform.parse(watchId, parser, context, aggParsers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -160,7 +160,7 @@ public class IndexActionIntegrationTests extends AbstractWatcherIntegrationTestC
|
||||||
.source(searchSource()
|
.source(searchSource()
|
||||||
.aggregation(dateHistogram("trend")
|
.aggregation(dateHistogram("trend")
|
||||||
.field("timestamp")
|
.field("timestamp")
|
||||||
.interval(DateHistogramInterval.DAY)))))
|
.dateHistogramInterval(DateHistogramInterval.DAY)))))
|
||||||
.addAction("index-buckets",
|
.addAction("index-buckets",
|
||||||
|
|
||||||
// this transform takes the bucket list and assigns it to `_doc`
|
// this transform takes the bucket list and assigns it to `_doc`
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class CompareConditionSearchTests extends AbstractWatcherIntegrationTestC
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("my-index")
|
SearchResponse response = client().prepareSearch("my-index")
|
||||||
.addAggregation(AggregationBuilders.dateHistogram("rate").field("_timestamp")
|
.addAggregation(AggregationBuilders.dateHistogram("rate").field("_timestamp")
|
||||||
.interval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC))
|
.dateHistogramInterval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
ExecutableCompareCondition condition = new ExecutableCompareCondition(
|
ExecutableCompareCondition condition = new ExecutableCompareCondition(
|
||||||
|
@ -70,7 +70,7 @@ public class CompareConditionSearchTests extends AbstractWatcherIntegrationTestC
|
||||||
|
|
||||||
response = client().prepareSearch("my-index")
|
response = client().prepareSearch("my-index")
|
||||||
.addAggregation(AggregationBuilders.dateHistogram("rate")
|
.addAggregation(AggregationBuilders.dateHistogram("rate")
|
||||||
.field("_timestamp").interval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC))
|
.field("_timestamp").dateHistogramInterval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("my-index")
|
SearchResponse response = client().prepareSearch("my-index")
|
||||||
.addAggregation(AggregationBuilders.dateHistogram("rate")
|
.addAggregation(AggregationBuilders.dateHistogram("rate")
|
||||||
.field("_timestamp").interval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC))
|
.field("_timestamp").dateHistogramInterval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
ExecutableScriptCondition condition = new ExecutableScriptCondition(
|
ExecutableScriptCondition condition = new ExecutableScriptCondition(
|
||||||
|
@ -77,7 +77,7 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa
|
||||||
|
|
||||||
response = client().prepareSearch("my-index")
|
response = client().prepareSearch("my-index")
|
||||||
.addAggregation(AggregationBuilders.dateHistogram("rate")
|
.addAggregation(AggregationBuilders.dateHistogram("rate")
|
||||||
.field("_timestamp").interval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC))
|
.field("_timestamp").dateHistogramInterval(DateHistogramInterval.HOUR).order(Histogram.Order.COUNT_DESC))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
ctx = mockExecutionContext("_name", new Payload.XContent(response));
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class WatcherUtilsTests extends ESTestCase {
|
||||||
IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, singletonMap("match_all", new MatchAllQueryParser()));
|
IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, singletonMap("match_all", new MatchAllQueryParser()));
|
||||||
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);
|
SearchRequest result = WatcherUtils.readSearchRequest(parser, ExecutableSearchInput.DEFAULT_SEARCH_TYPE, context, null);
|
||||||
|
|
||||||
assertThat(result.indices(), arrayContainingInAnyOrder(expectedRequest.indices()));
|
assertThat(result.indices(), arrayContainingInAnyOrder(expectedRequest.indices()));
|
||||||
assertThat(result.types(), arrayContainingInAnyOrder(expectedRequest.types()));
|
assertThat(result.types(), arrayContainingInAnyOrder(expectedRequest.types()));
|
||||||
|
@ -224,7 +224,7 @@ public class WatcherUtilsTests extends ESTestCase {
|
||||||
IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, singletonMap("match_all", new MatchAllQueryParser()));
|
IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, singletonMap("match_all", new MatchAllQueryParser()));
|
||||||
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);
|
SearchRequest result = WatcherUtils.readSearchRequest(parser, ExecutableSearchInput.DEFAULT_SEARCH_TYPE, context, null);
|
||||||
|
|
||||||
assertThat(result.indices(), arrayContainingInAnyOrder(indices));
|
assertThat(result.indices(), arrayContainingInAnyOrder(indices));
|
||||||
assertThat(result.types(), arrayContainingInAnyOrder(types));
|
assertThat(result.types(), arrayContainingInAnyOrder(types));
|
||||||
|
|
|
@ -350,10 +350,10 @@ 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:
|
||||||
IndicesQueriesRegistry queryRegistry = new IndicesQueriesRegistry(Settings.EMPTY,
|
IndicesQueriesRegistry queryRegistry = new IndicesQueriesRegistry(Settings.EMPTY,
|
||||||
singletonMap("match_all", new MatchAllQueryParser()));
|
singletonMap("match_all", new MatchAllQueryParser()));
|
||||||
parsers.put(SearchInput.TYPE, new SearchInputFactory(settings, client, queryRegistry));
|
parsers.put(SearchInput.TYPE, new SearchInputFactory(settings, client, queryRegistry, null));
|
||||||
return new InputRegistry(parsers);
|
return new InputRegistry(parsers);
|
||||||
default:
|
default:
|
||||||
parsers.put(SimpleInput.TYPE, new SimpleInputFactory(settings));
|
parsers.put(SimpleInput.TYPE, new SimpleInputFactory(settings));
|
||||||
return new InputRegistry(parsers);
|
return new InputRegistry(parsers);
|
||||||
|
@ -423,7 +423,7 @@ public class WatchTests extends ESTestCase {
|
||||||
ChainTransformFactory parser = new ChainTransformFactory();
|
ChainTransformFactory parser = new ChainTransformFactory();
|
||||||
factories.put(ChainTransform.TYPE, parser);
|
factories.put(ChainTransform.TYPE, parser);
|
||||||
factories.put(ScriptTransform.TYPE, new ScriptTransformFactory(settings, scriptService));
|
factories.put(ScriptTransform.TYPE, new ScriptTransformFactory(settings, scriptService));
|
||||||
factories.put(SearchTransform.TYPE, new SearchTransformFactory(settings, client, queryRegistry));
|
factories.put(SearchTransform.TYPE, new SearchTransformFactory(settings, client, queryRegistry, null));
|
||||||
TransformRegistry registry = new TransformRegistry(unmodifiableMap(factories));
|
TransformRegistry registry = new TransformRegistry(unmodifiableMap(factories));
|
||||||
parser.init(registry);
|
parser.init(registry);
|
||||||
return registry;
|
return registry;
|
||||||
|
|
Loading…
Reference in New Issue