Skip to content

Commit 388c475

Browse files
author
Max Hniebergall
committed
Only write EndpointVersion to index
1 parent 84c75f1 commit 388c475

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class ModelConfigurations implements ToFilteredXContentObject, VersionedN
2525
// is returned as part of a GetInferenceModelAction
2626
public static final String INDEX_ONLY_ID_FIELD_NAME = "model_id";
2727
public static final String INFERENCE_ID_FIELD_NAME = "inference_id";
28-
public static final String USE_ID_FOR_INDEX = "for_index";
28+
public static final String FOR_INDEX = "for_index"; // true if writing to index
2929
public static final String SERVICE = "service";
3030
public static final String SERVICE_SETTINGS = "service_settings";
3131
public static final String OLD_TASK_SETTINGS = "task_settings";
@@ -194,7 +194,7 @@ public String getEndpointVersion() {
194194
@Override
195195
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
196196
builder.startObject();
197-
if (params.paramAsBoolean(USE_ID_FOR_INDEX, false)) {
197+
if (params.paramAsBoolean(FOR_INDEX, false)) {
198198
builder.field(INDEX_ONLY_ID_FIELD_NAME, inferenceEntityId);
199199
} else {
200200
builder.field(INFERENCE_ID_FIELD_NAME, inferenceEntityId);
@@ -209,15 +209,17 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
209209
if (params.paramAsBoolean(INCLUDE_PARAMETERS, true)) { // default true so that REST requests get parameters
210210
builder.field(PARAMETERS, taskSettings);
211211
}
212-
builder.field(ENDPOINT_VERSION_FIELD_NAME, endpointVersion);
212+
if (params.paramAsBoolean(FOR_INDEX, false)) {
213+
builder.field(ENDPOINT_VERSION_FIELD_NAME, endpointVersion); // only write endpoint version for index, not for REST
214+
}
213215
builder.endObject();
214216
return builder;
215217
}
216218

217219
@Override
218220
public XContentBuilder toFilteredXContent(XContentBuilder builder, Params params) throws IOException {
219221
builder.startObject();
220-
if (params.paramAsBoolean(USE_ID_FOR_INDEX, false)) {
222+
if (params.paramAsBoolean(FOR_INDEX, false)) {
221223
builder.field(INDEX_ONLY_ID_FIELD_NAME, inferenceEntityId);
222224
} else {
223225
builder.field(INFERENCE_ID_FIELD_NAME, inferenceEntityId);
@@ -232,7 +234,9 @@ public XContentBuilder toFilteredXContent(XContentBuilder builder, Params params
232234
if (params.paramAsBoolean(INCLUDE_PARAMETERS, true)) { // default true so that REST requests get parameters
233235
builder.field(PARAMETERS, taskSettings);
234236
}
237+
if (params.paramAsBoolean(FOR_INDEX, false)) {
235238
builder.field(ENDPOINT_VERSION_FIELD_NAME, endpointVersion);
239+
}
236240
builder.endObject();
237241
return builder;
238242
}

0 commit comments

Comments
 (0)