From 51e8b08443417d81fa2efa1dbebd043705ccab10 Mon Sep 17 00:00:00 2001 From: bowenlan-amzn Date: Thu, 1 Aug 2024 20:41:03 -0700 Subject: [PATCH] wrap up for 2.17 Signed-off-by: bowenlan-amzn --- .ci/bwcVersions | 1 + .../src/main/java/org/opensearch/Version.java | 1 + .../index/query/TermsQueryBuilder.java | 5 ++--- .../org/opensearch/indices/TermsLookup.java | 4 ++-- .../index/query/TermsQueryBuilderTests.java | 19 ------------------- 5 files changed, 6 insertions(+), 24 deletions(-) diff --git a/.ci/bwcVersions b/.ci/bwcVersions index a738eb54e17f6..771bfe694b698 100644 --- a/.ci/bwcVersions +++ b/.ci/bwcVersions @@ -36,3 +36,4 @@ BWC_VERSION: - "2.15.0" - "2.15.1" - "2.16.0" + - "2.17.0" diff --git a/libs/core/src/main/java/org/opensearch/Version.java b/libs/core/src/main/java/org/opensearch/Version.java index b647a92d6708a..c2d8ce9be29dd 100644 --- a/libs/core/src/main/java/org/opensearch/Version.java +++ b/libs/core/src/main/java/org/opensearch/Version.java @@ -107,6 +107,7 @@ public class Version implements Comparable, ToXContentFragment { public static final Version V_2_15_0 = new Version(2150099, org.apache.lucene.util.Version.LUCENE_9_10_0); public static final Version V_2_15_1 = new Version(2150199, org.apache.lucene.util.Version.LUCENE_9_10_0); public static final Version V_2_16_0 = new Version(2160099, org.apache.lucene.util.Version.LUCENE_9_11_1); + public static final Version V_2_17_0 = new Version(2170099, org.apache.lucene.util.Version.LUCENE_9_11_1); public static final Version V_3_0_0 = new Version(3000099, org.apache.lucene.util.Version.LUCENE_9_12_0); public static final Version CURRENT = V_3_0_0; 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 c63e03bff7516..ccd654a069f9b 100644 --- a/server/src/main/java/org/opensearch/index/query/TermsQueryBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/TermsQueryBuilder.java @@ -246,8 +246,7 @@ public TermsQueryBuilder(StreamInput in) throws IOException { termsLookup = in.readOptionalWriteable(TermsLookup::new); values = (List) in.readGenericValue(); this.supplier = null; - // TODO change all V_2_16_0 to V_2_17_0 - if (in.getVersion().onOrAfter(Version.V_2_16_0)) { + if (in.getVersion().onOrAfter(Version.V_2_17_0)) { valueType = in.readEnum(ValueType.class); } } @@ -260,7 +259,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { out.writeString(fieldName); out.writeOptionalWriteable(termsLookup); out.writeGenericValue(values); - if (out.getVersion().onOrAfter(Version.V_2_16_0)) { + if (out.getVersion().onOrAfter(Version.V_2_17_0)) { out.writeEnum(valueType); } } diff --git a/server/src/main/java/org/opensearch/indices/TermsLookup.java b/server/src/main/java/org/opensearch/indices/TermsLookup.java index ba1b4ed6274b5..7337ed31ce41e 100644 --- a/server/src/main/java/org/opensearch/indices/TermsLookup.java +++ b/server/src/main/java/org/opensearch/indices/TermsLookup.java @@ -87,7 +87,7 @@ public TermsLookup(StreamInput in) throws IOException { path = in.readString(); index = in.readString(); routing = in.readOptionalString(); - if (in.getVersion().onOrAfter(Version.V_2_16_0)) { + if (in.getVersion().onOrAfter(Version.V_2_17_0)) { store = in.readBoolean(); } } @@ -101,7 +101,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(path); out.writeString(index); out.writeOptionalString(routing); - if (out.getVersion().onOrAfter(Version.V_2_16_0)) { + if (out.getVersion().onOrAfter(Version.V_2_17_0)) { out.writeBoolean(store); } } diff --git a/server/src/test/java/org/opensearch/index/query/TermsQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/TermsQueryBuilderTests.java index 0f32a5d6dc152..cfe9fed3bc97c 100644 --- a/server/src/test/java/org/opensearch/index/query/TermsQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/TermsQueryBuilderTests.java @@ -449,23 +449,4 @@ public void testTermsLookupBitmap() throws IOException { Query luceneQuery = rewritten.toQuery(context); assertTrue(luceneQuery instanceof IndexOrDocValuesQuery); } - - // public void testTermsLookupBitmapFail() throws IOException { - // RoaringBitmap bitmap = new RoaringBitmap(); - // bitmap.add(111); - // bitmap.add(333); - // byte[] array = new byte[bitmap.serializedSizeInBytes()]; - // bitmap.serialize(ByteBuffer.wrap(array)); - // randomTerms = List.of(new BytesArray(array), new BytesArray(array)); // this will be fetched back by terms lookup - // - // TermsQueryBuilder query = new TermsQueryBuilder(INT_FIELD_NAME, randomTermsLookup().store(true)).valueType( - // TermsQueryBuilder.ValueType.BITMAP - // ); - // QueryShardContext context = createShardContext(); - // IllegalArgumentException e = expectThrows( - // IllegalArgumentException.class, - // () -> rewriteQuery(query, new QueryShardContext(context)) - // ); - // assertEquals("Invalid value for bitmap type: Expected a single base64 encoded serialized bitmap.", e.getMessage()); - // } }