3636 */
3737public class FetchSourceContext implements Writeable , ToXContentObject {
3838
39- public static final ParseField INCLUDE_VECTORS_FIELD = new ParseField ("include_vectors " );
39+ public static final ParseField EXCLUDE_VECTORS_FIELD = new ParseField ("exclude_vectors " );
4040 public static final ParseField INCLUDES_FIELD = new ParseField ("includes" , "include" );
4141 public static final ParseField EXCLUDES_FIELD = new ParseField ("excludes" , "exclude" );
4242
@@ -50,7 +50,7 @@ public class FetchSourceContext implements Writeable, ToXContentObject {
5050 private final boolean fetchSource ;
5151 private final String [] includes ;
5252 private final String [] excludes ;
53- private final Boolean includeVectors ;
53+ private final Boolean excludeVectors ;
5454
5555 public static FetchSourceContext of (boolean fetchSource ) {
5656 return fetchSource ? FETCH_SOURCE : DO_NOT_FETCH_SOURCE ;
@@ -62,52 +62,52 @@ public static FetchSourceContext of(boolean fetchSource, @Nullable String[] incl
6262
6363 public static FetchSourceContext of (
6464 boolean fetchSource ,
65- Boolean includeVectors ,
65+ Boolean excludeVectors ,
6666 @ Nullable String [] includes ,
6767 @ Nullable String [] excludes
6868 ) {
69- if (includeVectors == null && (includes == null || includes .length == 0 ) && (excludes == null || excludes .length == 0 )) {
69+ if (excludeVectors == null && (includes == null || includes .length == 0 ) && (excludes == null || excludes .length == 0 )) {
7070 return of (fetchSource );
7171 }
72- return new FetchSourceContext (fetchSource , includeVectors , includes , excludes );
72+ return new FetchSourceContext (fetchSource , excludeVectors , includes , excludes );
7373 }
7474
75- private FetchSourceContext (boolean fetchSource , Boolean includeVectors , @ Nullable String [] includes , @ Nullable String [] excludes ) {
75+ private FetchSourceContext (boolean fetchSource , Boolean excludeVectors , @ Nullable String [] includes , @ Nullable String [] excludes ) {
7676 this .fetchSource = fetchSource ;
77- this .includeVectors = includeVectors ;
77+ this .excludeVectors = excludeVectors ;
7878 this .includes = includes == null ? Strings .EMPTY_ARRAY : includes ;
7979 this .excludes = excludes == null ? Strings .EMPTY_ARRAY : excludes ;
8080 }
8181
8282 public static FetchSourceContext readFrom (StreamInput in ) throws IOException {
8383 final boolean fetchSource = in .readBoolean ();
84- final Boolean includeVectors = isVersionCompatibleWithIncludeVectors (in .getTransportVersion ()) ? in .readOptionalBoolean () : null ;
84+ final Boolean excludeVectors = isVersionCompatibleWithExcludeVectors (in .getTransportVersion ()) ? in .readOptionalBoolean () : null ;
8585 final String [] includes = in .readStringArray ();
8686 final String [] excludes = in .readStringArray ();
87- return of (fetchSource , includeVectors , includes , excludes );
87+ return of (fetchSource , excludeVectors , includes , excludes );
8888 }
8989
9090 @ Override
9191 public void writeTo (StreamOutput out ) throws IOException {
9292 out .writeBoolean (fetchSource );
93- if (isVersionCompatibleWithIncludeVectors (out .getTransportVersion ())) {
94- out .writeOptionalBoolean (includeVectors );
93+ if (isVersionCompatibleWithExcludeVectors (out .getTransportVersion ())) {
94+ out .writeOptionalBoolean (excludeVectors );
9595 }
9696 out .writeStringArray (includes );
9797 out .writeStringArray (excludes );
9898 }
9999
100- private static boolean isVersionCompatibleWithIncludeVectors (TransportVersion version ) {
101- return version .isPatchFrom (TransportVersions .SEARCH_SOURCE_INCLUDE_VECTORS_PARAM_8_19 )
102- || version .onOrAfter (TransportVersions .SEARCH_SOURCE_INCLUDE_VECTORS_PARAM );
100+ private static boolean isVersionCompatibleWithExcludeVectors (TransportVersion version ) {
101+ return version .isPatchFrom (TransportVersions .SEARCH_SOURCE_EXCLUDE_VECTORS_PARAM_8_19 )
102+ || version .onOrAfter (TransportVersions .SEARCH_SOURCE_EXCLUDE_VECTORS_PARAM );
103103 }
104104
105105 public boolean fetchSource () {
106106 return this .fetchSource ;
107107 }
108108
109- public Boolean includeVectors () {
110- return this .includeVectors ;
109+ public Boolean excludeVectors () {
110+ return this .excludeVectors ;
111111 }
112112
113113 public String [] includes () {
@@ -168,7 +168,7 @@ public static FetchSourceContext fromXContent(XContentParser parser) throws IOEx
168168
169169 XContentParser .Token token = parser .currentToken ();
170170 boolean fetchSource = true ;
171- Boolean includeVectors = null ;
171+ Boolean excludeVectors = null ;
172172 String [] includes = Strings .EMPTY_ARRAY ;
173173 String [] excludes = Strings .EMPTY_ARRAY ;
174174 if (token == XContentParser .Token .VALUE_BOOLEAN ) {
@@ -203,8 +203,8 @@ public static FetchSourceContext fromXContent(XContentParser parser) throws IOEx
203203 includes = new String [] { parser .text () };
204204 } else if (EXCLUDES_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
205205 excludes = new String [] { parser .text () };
206- } else if (INCLUDE_VECTORS_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
207- includeVectors = parser .booleanValue ();
206+ } else if (EXCLUDE_VECTORS_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
207+ excludeVectors = parser .booleanValue ();
208208 } else {
209209 throw new ParsingException (
210210 parser .getTokenLocation (),
@@ -213,8 +213,8 @@ public static FetchSourceContext fromXContent(XContentParser parser) throws IOEx
213213 );
214214 }
215215 } else if (token == XContentParser .Token .VALUE_BOOLEAN ) {
216- if (INCLUDE_VECTORS_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
217- includeVectors = parser .booleanValue ();
216+ if (EXCLUDE_VECTORS_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
217+ excludeVectors = parser .booleanValue ();
218218 } else {
219219 throw new ParsingException (
220220 parser .getTokenLocation (),
@@ -247,7 +247,7 @@ public static FetchSourceContext fromXContent(XContentParser parser) throws IOEx
247247 parser .getTokenLocation ()
248248 );
249249 }
250- return FetchSourceContext .of (fetchSource , includeVectors , includes , excludes );
250+ return FetchSourceContext .of (fetchSource , excludeVectors , includes , excludes );
251251 }
252252
253253 private static String [] parseStringArray (XContentParser parser , String currentFieldName ) throws IOException {
@@ -273,8 +273,8 @@ private static String[] parseStringArray(XContentParser parser, String currentFi
273273 public XContentBuilder toXContent (XContentBuilder builder , Params params ) throws IOException {
274274 if (fetchSource ) {
275275 builder .startObject ();
276- if (includeVectors != null ) {
277- builder .field (INCLUDE_VECTORS_FIELD .getPreferredName (), includeVectors );
276+ if (excludeVectors != null ) {
277+ builder .field (EXCLUDE_VECTORS_FIELD .getPreferredName (), excludeVectors );
278278 }
279279 builder .array (INCLUDES_FIELD .getPreferredName (), includes );
280280 builder .array (EXCLUDES_FIELD .getPreferredName (), excludes );
@@ -293,7 +293,7 @@ public boolean equals(Object o) {
293293 FetchSourceContext that = (FetchSourceContext ) o ;
294294
295295 if (fetchSource != that .fetchSource ) return false ;
296- if (includeVectors != that .includeVectors ) return false ;
296+ if (excludeVectors != that .excludeVectors ) return false ;
297297 if (Arrays .equals (excludes , that .excludes ) == false ) return false ;
298298 if (Arrays .equals (includes , that .includes ) == false ) return false ;
299299
@@ -302,7 +302,7 @@ public boolean equals(Object o) {
302302
303303 @ Override
304304 public int hashCode () {
305- int result = Objects .hash (fetchSource , includeVectors );
305+ int result = Objects .hash (fetchSource , excludeVectors );
306306 result = 31 * result + Arrays .hashCode (includes );
307307 result = 31 * result + Arrays .hashCode (excludes );
308308 return result ;
0 commit comments