Skip to content

Commit

Permalink
bwc in transport stream
Browse files Browse the repository at this point in the history
Signed-off-by: bowenlan-amzn <bowenlan23@gmail.com>
  • Loading branch information
bowenlan-amzn committed Jul 29, 2024
1 parent b388d59 commit 577e6d0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -80,14 +81,14 @@
public class TermsQueryBuilder extends AbstractQueryBuilder<TermsQueryBuilder> {
public static final String NAME = "terms";


private final String fieldName;
private final List<?> values;
private final TermsLookup termsLookup;
private final Supplier<List<?>> supplier;

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;
Expand Down Expand Up @@ -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<List<?>> supplier) {
Expand All @@ -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
Expand All @@ -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() {
Expand Down
12 changes: 11 additions & 1 deletion server/src/main/java/org/opensearch/indices/TermsLookup.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
Expand All @@ -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;
Expand Down

0 comments on commit 577e6d0

Please sign in to comment.