Updated the watch_history template

- Disabled the search request body/template fields as they're too volatile to have mappings (applied for both for `search` input and transform)
- Disabled watch level transform result payload

Original commit: elastic/x-pack-elasticsearch@f69b237234
This commit is contained in:
uboness 2015-05-16 01:00:41 +02:00
parent a52a833264
commit b11f457fb7
3 changed files with 39 additions and 10 deletions

View File

@ -9,8 +9,18 @@
"watch_record": {
"dynamic_templates": [
{
"disabled_fields": {
"path_match": "execution_result\\.((input\\..+)|(actions\\.transform))\\.payload",
"disabled_payload_fields": {
"path_match": "execution_result\\.((input\\..+)|(actions\\.transform\\..+)|(transform\\..+))\\.payload",
"match_pattern": "regex",
"mapping": {
"type": "object",
"enabled": false
}
}
},
{
"disabled_search_request_body_fields": {
"path_match": "execution_result\\.((input)|(actions\\.transform.*)|(transform.*))\\.search\\.request\\.(body|template)",
"match_pattern": "regex",
"mapping": {
"type": "object",
@ -120,7 +130,23 @@
},
"transform" : {
"type" : "object",
"enabled" : false
"dynamic" : true,
"properties" : {
"search" : {
"type" : "object",
"dynamic" : true,
"properties" : {
"indices" : {
"type" : "string",
"index" : "not_analyzed"
},
"types" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
}
},
"actions": {
"type": "nested",
@ -206,10 +232,6 @@
}
}
}
},
"transform" : {
"type" : "object",
"enabled" : false
}
}
}

View File

@ -16,6 +16,7 @@ import org.elasticsearch.watcher.test.AbstractWatcherIntegrationTests;
import org.elasticsearch.watcher.transport.actions.put.PutWatchResponse;
import org.junit.Test;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource;
import static org.elasticsearch.watcher.actions.ActionBuilders.loggingAction;
@ -54,7 +55,8 @@ public class HistoryTemplateSearchInputMappingsTests extends AbstractWatcherInte
PutWatchResponse putWatchResponse = watcherClient().preparePutWatch("_id").setSource(watchBuilder()
.trigger(schedule(interval("5s")))
.input(searchInput(new SearchRequest().indices(index).types(type).searchType(SearchType.QUERY_AND_FETCH)))
.input(searchInput(new SearchRequest().indices(index).types(type).searchType(SearchType.QUERY_AND_FETCH)
.source(searchSource().query(matchAllQuery()))))
.condition(alwaysCondition())
.addAction("logger", loggingAction("indexed")))
.get();
@ -71,6 +73,7 @@ public class HistoryTemplateSearchInputMappingsTests extends AbstractWatcherInte
.aggregation(terms("input_search_type").field("execution_result.input.search.request.search_type"))
.aggregation(terms("input_indices").field("execution_result.input.search.request.indices"))
.aggregation(terms("input_types").field("execution_result.input.search.request.types"))
.aggregation(terms("input_body").field("execution_result.input.search.request.body"))
.buildAsBytes())
.get();
@ -96,5 +99,9 @@ public class HistoryTemplateSearchInputMappingsTests extends AbstractWatcherInte
assertThat(terms.getBuckets().size(), is(1));
assertThat(terms.getBucketByKey(type), notNullValue());
assertThat(terms.getBucketByKey(type).getDocCount(), is(1L));
terms = aggs.get("input_body");
assertThat(terms, notNullValue());
assertThat(terms.getBuckets().size(), is(0));
}
}

View File

@ -98,8 +98,8 @@ public class HistoryTemplateTransformMappingsTests extends AbstractWatcherIntegr
try {
Map<String, Object> source = metadata.getSourceAsMap();
logger.info("checking index [{}] with metadata:\n[{}]", metadatas.key, metadata.source().toString());
assertThat(extractValue("properties.execution_result.properties.transform.enabled", source), is((Object) false));
assertThat(extractValue("properties.execution_result.properties.actions.properties.transform.enabled", source), is((Object) false));
assertThat(extractValue("properties.execution_result.properties.transform.properties.script.properties.payload.enabled", source), is((Object) false));
assertThat(extractValue("properties.execution_result.properties.actions.properties.transform.properties.script.properties.payload.enabled", source), is((Object) false));
} catch (IOException e) {
throw new RuntimeException(e);
}