From 577e6d0d5cabefa30dd4d2e8047d979cac332089 Mon Sep 17 00:00:00 2001 From: bowenlan-amzn Date: Mon, 29 Jul 2024 11:39:02 -0700 Subject: [PATCH] bwc in transport stream Signed-off-by: bowenlan-amzn --- .../opensearch/index/query/TermsQueryBuilder.java | 13 ++++++++++--- .../java/org/opensearch/indices/TermsLookup.java | 12 +++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/query/TermsQueryBuilder.java b/server/src/main/java/org/opensearch/index/query/TermsQueryBuilder.java index a083483eacab7..1c47d7a7c2c37 100644 --- a/server/src/main/java/org/opensearch/index/query/TermsQueryBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/TermsQueryBuilder.java @@ -37,6 +37,7 @@ import org.apache.lucene.search.Query; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRefBuilder; +import org.opensearch.Version; import org.opensearch.action.get.GetRequest; import org.opensearch.client.Client; import org.opensearch.common.SetOnce; @@ -80,7 +81,6 @@ public class TermsQueryBuilder extends AbstractQueryBuilder { public static final String NAME = "terms"; - private final String fieldName; private final List values; private final TermsLookup termsLookup; @@ -88,6 +88,7 @@ public class TermsQueryBuilder extends AbstractQueryBuilder { private static final ParseField VALUE_TYPE_FIELD = new ParseField("value_type"); private String valueType; + public final TermsQueryBuilder valueType(String valueType) { this.valueType = valueType; return this; @@ -199,8 +200,8 @@ public TermsQueryBuilder(String fieldName, Iterable values) { } private TermsQueryBuilder(String fieldName, Iterable values, String valueType) { - this(fieldName, values); - this.valueType = valueType; + this(fieldName, values); + this.valueType = valueType; } private TermsQueryBuilder(String fieldName, Supplier> supplier) { @@ -224,6 +225,9 @@ public TermsQueryBuilder(StreamInput in) throws IOException { termsLookup = in.readOptionalWriteable(TermsLookup::new); values = (List) in.readGenericValue(); this.supplier = null; + if (in.getVersion().after(Version.V_2_16_0)) { + valueType = in.readOptionalString(); + } } @Override @@ -234,6 +238,9 @@ protected void doWriteTo(StreamOutput out) throws IOException { out.writeString(fieldName); out.writeOptionalWriteable(termsLookup); out.writeGenericValue(values); + if (out.getVersion().after(Version.V_2_16_0)) { + out.writeOptionalString(valueType); + } } public String fieldName() { diff --git a/server/src/main/java/org/opensearch/indices/TermsLookup.java b/server/src/main/java/org/opensearch/indices/TermsLookup.java index bb4c36b89e054..7768df87b5486 100644 --- a/server/src/main/java/org/opensearch/indices/TermsLookup.java +++ b/server/src/main/java/org/opensearch/indices/TermsLookup.java @@ -87,6 +87,9 @@ public TermsLookup(StreamInput in) throws IOException { path = in.readString(); index = in.readString(); routing = in.readOptionalString(); + if (in.getVersion().after(Version.V_2_16_0)) { + store = in.readBoolean(); + } } @Override @@ -98,6 +101,9 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(path); out.writeString(index); out.writeOptionalString(routing); + if (out.getVersion().after(Version.V_2_16_0)) { + out.writeBoolean(store); + } } public String index() { @@ -122,7 +128,11 @@ public TermsLookup routing(String routing) { } private boolean store; - public boolean store() { return store; } + + public boolean store() { + return store; + } + public TermsLookup store(boolean store) { this.store = store; return this;