8
8
9
9
package org .elasticsearch .action .search ;
10
10
11
+ import org .elasticsearch .Version ;
11
12
import org .elasticsearch .action .IndicesRequest ;
12
13
import org .elasticsearch .action .OriginalIndices ;
13
14
import org .elasticsearch .action .support .IndicesOptions ;
15
+ import org .elasticsearch .common .Strings ;
14
16
import org .elasticsearch .common .io .stream .StreamInput ;
15
17
import org .elasticsearch .common .io .stream .StreamOutput ;
16
18
import org .elasticsearch .common .io .stream .Writeable ;
@@ -149,6 +151,14 @@ public CanMatchNodeRequest(StreamInput in) throws IOException {
149
151
source = in .readOptionalWriteable (SearchSourceBuilder ::new );
150
152
indicesOptions = IndicesOptions .readIndicesOptions (in );
151
153
searchType = SearchType .fromId (in .readByte ());
154
+ if (in .getVersion ().before (Version .V_8_0_0 )) {
155
+ // types no longer relevant so ignore
156
+ String [] types = in .readStringArray ();
157
+ if (types .length > 0 ) {
158
+ throw new IllegalStateException (
159
+ "types are no longer supported in search requests but found [" + Arrays .toString (types ) + "]" );
160
+ }
161
+ }
152
162
scroll = in .readOptionalWriteable (Scroll ::new );
153
163
requestCache = in .readOptionalBoolean ();
154
164
allowPartialSearchResults = in .readBoolean ();
@@ -167,6 +177,10 @@ public void writeTo(StreamOutput out) throws IOException {
167
177
out .writeOptionalWriteable (source );
168
178
indicesOptions .writeIndicesOptions (out );
169
179
out .writeByte (searchType .id ());
180
+ if (out .getVersion ().before (Version .V_8_0_0 )) {
181
+ // types not supported so send an empty array to previous versions
182
+ out .writeStringArray (Strings .EMPTY_ARRAY );
183
+ }
170
184
out .writeOptionalWriteable (scroll );
171
185
out .writeOptionalBoolean (requestCache );
172
186
out .writeBoolean (allowPartialSearchResults );
0 commit comments