From 508b462111d58180a2361a41e54c6991164cbf5e Mon Sep 17 00:00:00 2001 From: zhichao-aws Date: Wed, 27 Sep 2023 08:11:36 +0800 Subject: [PATCH] make query text and model id required Signed-off-by: zhichao-aws --- .../query/SparseEncodingQueryBuilder.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/opensearch/neuralsearch/query/SparseEncodingQueryBuilder.java b/src/main/java/org/opensearch/neuralsearch/query/SparseEncodingQueryBuilder.java index 430e6a1f6..07f581a9d 100644 --- a/src/main/java/org/opensearch/neuralsearch/query/SparseEncodingQueryBuilder.java +++ b/src/main/java/org/opensearch/neuralsearch/query/SparseEncodingQueryBuilder.java @@ -81,23 +81,23 @@ public static void initialize(MLCommonsClientAccessor mlClient) { public SparseEncodingQueryBuilder(StreamInput in) throws IOException { super(in); this.fieldName = in.readString(); - this.queryText = in.readOptionalString(); - this.modelId = in.readOptionalString(); + this.queryText = in.readString(); + this.modelId = in.readString(); } @Override protected void doWriteTo(StreamOutput out) throws IOException { out.writeString(fieldName); - out.writeOptionalString(queryText); - out.writeOptionalString(modelId); + out.writeString(queryText); + out.writeString(modelId); } @Override protected void doXContent(XContentBuilder xContentBuilder, Params params) throws IOException { xContentBuilder.startObject(NAME); xContentBuilder.startObject(fieldName); - if (null != queryText) xContentBuilder.field(QUERY_TEXT_FIELD.getPreferredName(), queryText); - if (null != modelId) xContentBuilder.field(MODEL_ID_FIELD.getPreferredName(), modelId); + xContentBuilder.field(QUERY_TEXT_FIELD.getPreferredName(), queryText); + xContentBuilder.field(MODEL_ID_FIELD.getPreferredName(), modelId); printBoostAndQueryName(xContentBuilder); xContentBuilder.endObject(); xContentBuilder.endObject();