55 */
66package org .elasticsearch .xpack .watcher .support .search ;
77
8- import org .apache .logging .log4j .LogManager ;
98import org .elasticsearch .ElasticsearchParseException ;
109import org .elasticsearch .action .search .SearchType ;
1110import org .elasticsearch .action .support .IndicesOptions ;
1413import org .elasticsearch .common .Strings ;
1514import org .elasticsearch .common .bytes .BytesArray ;
1615import org .elasticsearch .common .bytes .BytesReference ;
17- import org .elasticsearch .common .logging .DeprecationLogger ;
1816import org .elasticsearch .common .xcontent .ToXContentObject ;
1917import org .elasticsearch .common .xcontent .XContentBuilder ;
2018import org .elasticsearch .common .xcontent .XContentFactory ;
3836public class WatcherSearchTemplateRequest implements ToXContentObject {
3937
4038 private final String [] indices ;
41- private final String [] types ;
4239 private final SearchType searchType ;
4340 private final IndicesOptions indicesOptions ;
4441 private final Script template ;
4542 private final BytesReference searchSource ;
4643 private boolean restTotalHitsAsInt = true ;
4744
48- private static final DeprecationLogger deprecationLogger =
49- new DeprecationLogger (LogManager .getLogger (WatcherSearchTemplateRequest .class ));
50- public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in a watcher search request is deprecated." ;
51-
52- public WatcherSearchTemplateRequest (String [] indices , String [] types , SearchType searchType , IndicesOptions indicesOptions ,
45+ public WatcherSearchTemplateRequest (String [] indices , SearchType searchType , IndicesOptions indicesOptions ,
5346 BytesReference searchSource ) {
5447 this .indices = indices ;
55- this .types = types ;
5648 this .searchType = searchType ;
5749 this .indicesOptions = indicesOptions ;
5850 // Here we convert a watch search request body into an inline search template,
@@ -61,10 +53,9 @@ public WatcherSearchTemplateRequest(String[] indices, String[] types, SearchType
6153 this .searchSource = BytesArray .EMPTY ;
6254 }
6355
64- public WatcherSearchTemplateRequest (String [] indices , String [] types , SearchType searchType , IndicesOptions indicesOptions ,
56+ public WatcherSearchTemplateRequest (String [] indices , SearchType searchType , IndicesOptions indicesOptions ,
6557 Script template ) {
6658 this .indices = indices ;
67- this .types = types ;
6859 this .searchType = searchType ;
6960 this .indicesOptions = indicesOptions ;
7061 this .template = template ;
@@ -73,18 +64,16 @@ public WatcherSearchTemplateRequest(String[] indices, String[] types, SearchType
7364
7465 public WatcherSearchTemplateRequest (WatcherSearchTemplateRequest original , BytesReference source ) {
7566 this .indices = original .indices ;
76- this .types = original .types ;
7767 this .searchType = original .searchType ;
7868 this .indicesOptions = original .indicesOptions ;
7969 this .searchSource = source ;
8070 this .template = original .template ;
8171 this .restTotalHitsAsInt = original .restTotalHitsAsInt ;
8272 }
8373
84- private WatcherSearchTemplateRequest (String [] indices , String [] types , SearchType searchType , IndicesOptions indicesOptions ,
74+ private WatcherSearchTemplateRequest (String [] indices , SearchType searchType , IndicesOptions indicesOptions ,
8575 BytesReference searchSource , Script template ) {
8676 this .indices = indices ;
87- this .types = types ;
8877 this .searchType = searchType ;
8978 this .indicesOptions = indicesOptions ;
9079 this .template = template ;
@@ -100,10 +89,6 @@ public String[] getIndices() {
10089 return indices ;
10190 }
10291
103- public String [] getTypes () {
104- return types ;
105- }
106-
10792 public SearchType getSearchType () {
10893 return searchType ;
10994 }
@@ -146,9 +131,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
146131 if (indices != null ) {
147132 builder .array (INDICES_FIELD .getPreferredName (), indices );
148133 }
149- if (types != null ) {
150- builder .array (TYPES_FIELD .getPreferredName (), types );
151- }
152134 if (restTotalHitsAsInt ) {
153135 builder .field (REST_TOTAL_HITS_AS_INT_FIELD .getPreferredName (), restTotalHitsAsInt );
154136 }
@@ -186,7 +168,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
186168 */
187169 public static WatcherSearchTemplateRequest fromXContent (XContentParser parser , SearchType searchType ) throws IOException {
188170 List <String > indices = new ArrayList <>();
189- List <String > types = new ArrayList <>();
190171 IndicesOptions indicesOptions = DEFAULT_INDICES_OPTIONS ;
191172 BytesReference searchSource = null ;
192173 Script template = null ;
@@ -208,16 +189,6 @@ public static WatcherSearchTemplateRequest fromXContent(XContentParser parser, S
208189 currentFieldName + "] field, but instead found [" + token + "]" );
209190 }
210191 }
211- } else if (TYPES_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
212- deprecationLogger .deprecatedAndMaybeLog ("watcher_search_input" , TYPES_DEPRECATION_MESSAGE );
213- while ((token = parser .nextToken ()) != XContentParser .Token .END_ARRAY ) {
214- if (token == XContentParser .Token .VALUE_STRING ) {
215- types .add (parser .textOrNull ());
216- } else {
217- throw new ElasticsearchParseException ("could not read search request. expected string values in [" +
218- currentFieldName + "] field, but instead found [" + token + "]" );
219- }
220- }
221192 } else {
222193 throw new ElasticsearchParseException ("could not read search request. unexpected array field [" +
223194 currentFieldName + "]" );
@@ -284,10 +255,6 @@ public static WatcherSearchTemplateRequest fromXContent(XContentParser parser, S
284255 if (INDICES_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
285256 String indicesStr = parser .text ();
286257 indices .addAll (Arrays .asList (Strings .delimitedListToStringArray (indicesStr , "," , " \t " )));
287- } else if (TYPES_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
288- deprecationLogger .deprecatedAndMaybeLog ("watcher_search_input" , TYPES_DEPRECATION_MESSAGE );
289- String typesStr = parser .text ();
290- types .addAll (Arrays .asList (Strings .delimitedListToStringArray (typesStr , "," , " \t " )));
291258 } else if (SEARCH_TYPE_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
292259 searchType = SearchType .fromString (parser .text ().toLowerCase (Locale .ROOT ));
293260 } else if (REST_TOTAL_HITS_AS_INT_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
@@ -313,7 +280,7 @@ public static WatcherSearchTemplateRequest fromXContent(XContentParser parser, S
313280 }
314281
315282 WatcherSearchTemplateRequest request = new WatcherSearchTemplateRequest (indices .toArray (new String [0 ]),
316- types . size () == 0 ? null : types . toArray ( new String [ 0 ]), searchType , indicesOptions , searchSource , template );
283+ searchType , indicesOptions , searchSource , template );
317284 request .setRestTotalHitsAsInt (totalHitsAsInt );
318285 return request ;
319286 }
@@ -325,7 +292,6 @@ public boolean equals(Object o) {
325292
326293 WatcherSearchTemplateRequest other = (WatcherSearchTemplateRequest ) o ;
327294 return Arrays .equals (indices , other .indices ) &&
328- Arrays .equals (types , other .types ) &&
329295 Objects .equals (searchType , other .searchType ) &&
330296 Objects .equals (indicesOptions , other .indicesOptions ) &&
331297 Objects .equals (searchSource , other .searchSource ) &&
@@ -336,11 +302,10 @@ public boolean equals(Object o) {
336302
337303 @ Override
338304 public int hashCode () {
339- return Objects .hash (indices , types , searchType , indicesOptions , searchSource , template , restTotalHitsAsInt );
305+ return Objects .hash (indices , searchType , indicesOptions , searchSource , template , restTotalHitsAsInt );
340306 }
341307
342308 private static final ParseField INDICES_FIELD = new ParseField ("indices" );
343- private static final ParseField TYPES_FIELD = new ParseField ("types" );
344309 private static final ParseField BODY_FIELD = new ParseField ("body" );
345310 private static final ParseField SEARCH_TYPE_FIELD = new ParseField ("search_type" );
346311 private static final ParseField INDICES_OPTIONS_FIELD = new ParseField ("indices_options" );
0 commit comments