Skip to content

Commit a2517b1

Browse files
committed
rename include_vectors into exclude_vectors
1 parent 5258eac commit a2517b1

File tree

6 files changed

+34
-34
lines changed

6 files changed

+34
-34
lines changed

server/src/main/java/org/elasticsearch/rest/action/search/SearchCapabilities.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private SearchCapabilities() {}
5050

5151
private static final String SIGNIFICANT_TERMS_BACKGROUND_FILTER_AS_SUB = "significant_terms_background_filter_as_sub";
5252
private static final String SIGNIFICANT_TERMS_ON_NESTED_FIELDS = "significant_terms_on_nested_fields";
53-
private static final String INCLUDE_VECTORS_PARAM = "include_vectors_param";
53+
private static final String EXCLUDE_VECTORS_PARAM = "exclude_vectors_param";
5454

5555
public static final Set<String> CAPABILITIES;
5656
static {
@@ -72,7 +72,7 @@ private SearchCapabilities() {}
7272
capabilities.add(INDEX_SELECTOR_SYNTAX);
7373
capabilities.add(SIGNIFICANT_TERMS_BACKGROUND_FILTER_AS_SUB);
7474
capabilities.add(SIGNIFICANT_TERMS_ON_NESTED_FIELDS);
75-
capabilities.add(INCLUDE_VECTORS_PARAM);
75+
capabilities.add(EXCLUDE_VECTORS_PARAM);
7676
CAPABILITIES = Set.copyOf(capabilities);
7777
}
7878
}

server/src/main/java/org/elasticsearch/search/fetch/FetchContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private static FetchSourceContext buildFetchSourceContext(SearchContext in) {
7070
if (SourceFieldMapper.NAME.equals(field)) {
7171
fsc = fsc == null
7272
? FetchSourceContext.of(true)
73-
: FetchSourceContext.of(true, fsc.includeVectors(), fsc.includes(), fsc.excludes());
73+
: FetchSourceContext.of(true, fsc.excludeVectors(), fsc.includes(), fsc.excludes());
7474
}
7575
}
7676
}

server/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ private static boolean shouldExcludeVectorsFromSource(SearchContext context) {
453453
if (context.fetchSourceContext() == null) {
454454
return false;
455455
}
456-
return context.fetchSourceContext().includeVectors() != null && context.fetchSourceContext().includeVectors() == false;
456+
return context.fetchSourceContext().excludeVectors() != null && context.fetchSourceContext().excludeVectors();
457457
}
458458

459459
/**
@@ -502,7 +502,7 @@ private static SourceFilter maybeExcludeNonSemanticTextVectorFields(SearchContex
502502
? FetchSourceContext.of(true, false, null, lateExcludes.toArray(String[]::new))
503503
: FetchSourceContext.of(
504504
context.fetchSourceContext().fetchSource(),
505-
context.fetchSourceContext().includeVectors(),
505+
context.fetchSourceContext().excludeVectors(),
506506
context.fetchSourceContext().includes(),
507507
lateExcludes.toArray(String[]::new)
508508
);

server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchSourceContext.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*/
3737
public 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;

server/src/test/java/org/elasticsearch/search/fetch/subphase/FetchSourceContextTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ protected FetchSourceContext mutateInstance(FetchSourceContext instance) {
4646
return switch (randomInt(2)) {
4747
case 0 -> FetchSourceContext.of(
4848
true,
49-
instance.includeVectors() != null ? instance.includeVectors() == false : randomBoolean(),
49+
instance.excludeVectors() != null ? instance.excludeVectors() == false : randomBoolean(),
5050
instance.includes(),
5151
instance.excludes()
5252
);
5353
case 1 -> FetchSourceContext.of(
5454
true,
55-
instance.includeVectors(),
55+
instance.excludeVectors(),
5656
randomArray(instance.includes().length + 1, instance.includes().length + 5, String[]::new, () -> randomAlphaOfLength(5)),
5757
instance.excludes()
5858
);
5959
case 2 -> FetchSourceContext.of(
6060
true,
61-
instance.includeVectors(),
61+
instance.excludeVectors(),
6262
instance.includes(),
6363
randomArray(instance.excludes().length + 1, instance.excludes().length + 5, String[]::new, () -> randomAlphaOfLength(5))
6464
);

0 commit comments

Comments
 (0)