Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"actions": {
"test_index": {
"index": {
"index": "test",
"doc_type": "test2"
"index": "test"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"actions": {
"test_index": {
"index": {
"index": "test",
"doc_type": "test2"
"index": "test"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ teardown:
"indexme" : {
"index" : {
"index" : "my_test_index",
"doc_type" : "my-type",
"doc_id": "my-id"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ teardown:
},
"index" : {
"index" : "my_test_index",
"doc_type" : "my-type",
"doc_id": "my-id"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"actions": {
"test_index": {
"index": {
"index": "test",
"doc_type": "test2"
"index": "test"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ teardown:
"actions": {
"test_index": {
"index": {
"index": "test",
"doc_type": "test2"
"index": "test"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ teardown:
"indexme" : {
"index" : {
"index" : "my_test_index",
"doc_type" : "my-type",
"doc_id": "my-id"
}
}
Expand Down Expand Up @@ -87,7 +86,6 @@ teardown:
"indexme" : {
"index" : {
"index" : "my_test_index",
"doc_type" : "my-type",
"doc_id": "my-id"
}
}
Expand Down Expand Up @@ -130,7 +128,6 @@ teardown:
"indexme" : {
"index" : {
"index" : "my_test_index",
"doc_type" : "my-type",
"refresh" : "wait_for",
"doc_id": "my-id"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ setup:
- do:
index:
index: my_test_index
type: doc
id: my_id
refresh: true
body: >
Expand Down Expand Up @@ -49,7 +48,6 @@ setup:
"indexme" : {
"index" : {
"index" : "my_test_index",
"doc_type" : "doc",
"doc_id": "my-id"
}
}
Expand All @@ -64,7 +62,6 @@ setup:
- do:
get:
index: my_test_index
type: doc
id: my_id

- match: { _source.key: "value" }
Expand All @@ -82,7 +79,6 @@ setup:
- do:
index:
index: my_test_index
type: doc
id: my_id
refresh: true
body: >
Expand Down Expand Up @@ -123,7 +119,6 @@ setup:
"indexme" : {
"index" : {
"index" : "my_test_index",
"doc_type" : "doc",
"doc_id": "my-id"
}
}
Expand All @@ -138,7 +133,6 @@ setup:
- do:
get:
index: my_test_index
type: doc
id: my_id

- match: { _source.key: "value" }
Expand Down Expand Up @@ -183,7 +177,6 @@ setup:
"indexme" : {
"index" : {
"index" : "my_test_index",
"doc_type" : "doc",
"doc_id": "my-id"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"indexme" : {
"index" : {
"index" : "my_test_index",
"doc_type" : "my-type",
"doc_id": "my-id"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ teardown:
"actions": {
"test_index": {
"index": {
"index": "test",
"doc_type": "test2"
"index": "test"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
"actions": {
"test_index": {
"index": {
"index": "test",
"doc_type": "test2"
"index": "test"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
"actions": {
"test_index": {
"index": {
"index": "test",
"doc_type": "test2"
"index": "test"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ teardown:
"actions": {
"test_index": {
"index": {
"index": "test",
"doc_type": "test2"
"index": "test"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ teardown:
"test_index": {
"throttle_period" : "10s",
"index": {
"index": "test",
"doc_type": "test2"
"index": "test"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ teardown:
"actions": {
"test_index": {
"index": {
"index": "test",
"doc_type": "test2"
"index": "test"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ teardown:
}
},
"index": {
"index": "test",
"doc_type": "test2"
"index": "test"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ teardown:
"test_index": {
"index": {
"index": "my_test_index",
"doc_type": "test2",
"doc_id": "test_id1"
}
}
Expand Down Expand Up @@ -86,8 +85,7 @@ teardown:
"actions": {
"test_index": {
"index": {
"index": "my_test_index",
"doc_type": "test2"
"index": "my_test_index"
}
}
}
Expand Down Expand Up @@ -143,8 +141,7 @@ teardown:
"actions": {
"test_index": {
"index": {
"index": "my_test_index",
"doc_type": "test2"
"index": "my_test_index"
}
}
}
Expand Down Expand Up @@ -202,8 +199,7 @@ teardown:
"actions": {
"test_index": {
"index": {
"index": "my_test_index",
"doc_type": "test2"
"index": "my_test_index"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ setup:
- do:
index:
index: my_test_index
type: doc
id: my_id
refresh: true
body: >
Expand Down Expand Up @@ -97,7 +96,6 @@ setup:
},
"index" : {
"index" : "my_test_index",
"doc_type" : "doc",
"doc_id": "my-id"
}
}
Expand All @@ -108,7 +106,6 @@ setup:
- do:
get:
index: my_test_index
type: doc
id: my_id

- match: { _source.key: "value" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
*/
package org.elasticsearch.xpack.watcher.actions.index;

import org.apache.logging.log4j.LogManager;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
Expand All @@ -34,6 +36,9 @@ public class IndexAction implements Action {
@Nullable final DateTimeZone dynamicNameTimeZone;
@Nullable final RefreshPolicy refreshPolicy;

private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(IndexAction.class));
public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in a watcher index action is deprecated.";

public IndexAction(@Nullable String index, @Nullable String docType, @Nullable String docId,
@Nullable String executionTimeField,
@Nullable TimeValue timeout, @Nullable DateTimeZone dynamicNameTimeZone, @Nullable RefreshPolicy refreshPolicy) {
Expand Down Expand Up @@ -151,6 +156,7 @@ public static IndexAction parse(String watchId, String actionId, XContentParser
}
} else if (token == XContentParser.Token.VALUE_STRING) {
if (Field.DOC_TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
deprecationLogger.deprecatedAndMaybeLog("watcher_index_action", TYPES_DEPRECATION_MESSAGE);
docType = parser.text();
} else if (Field.DOC_ID.match(currentFieldName, parser.getDeprecationHandler())) {
docId = parser.text();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
package org.elasticsearch.xpack.watcher.support.search;

import org.apache.logging.log4j.LogManager;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.action.support.IndicesOptions;
Expand All @@ -13,6 +14,7 @@
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
Expand Down Expand Up @@ -43,6 +45,10 @@ public class WatcherSearchTemplateRequest implements ToXContentObject {
private final BytesReference searchSource;
private boolean restTotalHitsAsInt = true;

private static final DeprecationLogger deprecationLogger =
new DeprecationLogger(LogManager.getLogger(WatcherSearchTemplateRequest.class));
public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in a watcher search request is deprecated.";

public WatcherSearchTemplateRequest(String[] indices, String[] types, SearchType searchType, IndicesOptions indicesOptions,
BytesReference searchSource) {
this.indices = indices;
Expand Down Expand Up @@ -203,6 +209,7 @@ public static WatcherSearchTemplateRequest fromXContent(XContentParser parser, S
}
}
} else if (TYPES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
deprecationLogger.deprecatedAndMaybeLog("watcher_search_input", TYPES_DEPRECATION_MESSAGE);
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
if (token == XContentParser.Token.VALUE_STRING) {
types.add(parser.textOrNull());
Expand Down Expand Up @@ -278,6 +285,7 @@ public static WatcherSearchTemplateRequest fromXContent(XContentParser parser, S
String indicesStr = parser.text();
indices.addAll(Arrays.asList(Strings.delimitedListToStringArray(indicesStr, ",", " \t")));
} else if (TYPES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
deprecationLogger.deprecatedAndMaybeLog("watcher_search_input", TYPES_DEPRECATION_MESSAGE);
String typesStr = parser.text();
types.addAll(Arrays.asList(Strings.delimitedListToStringArray(typesStr, ",", " \t")));
} else if (SEARCH_TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
Expand Down Expand Up @@ -305,7 +313,7 @@ public static WatcherSearchTemplateRequest fromXContent(XContentParser parser, S
}

WatcherSearchTemplateRequest request = new WatcherSearchTemplateRequest(indices.toArray(new String[0]),
types.toArray(new String[0]), searchType, indicesOptions, searchSource, template);
types.size() == 0 ? null : types.toArray(new String[0]), searchType, indicesOptions, searchSource, template);
request.setRestTotalHitsAsInt(totalHitsAsInt);
return request;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public String renderTemplate(Script source, WatchExecutionContext ctx, Payload p

public SearchRequest toSearchRequest(WatcherSearchTemplateRequest request) throws IOException {
SearchRequest searchRequest = new SearchRequest(request.getIndices());
searchRequest.types(request.getTypes());
if (request.getTypes() != null) {
searchRequest.types(request.getTypes());
}
searchRequest.searchType(request.getSearchType());
searchRequest.indicesOptions(request.getIndicesOptions());
SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
Expand Down
Loading