From dde2608139d78b36890f4ed5f9157a1e2ffae2a7 Mon Sep 17 00:00:00 2001 From: hye-on Date: Mon, 13 Jan 2025 17:57:23 +0900 Subject: [PATCH 01/11] Fix getTime field name to time in GetStats (#16894) Signed-off-by: hye-on --- CHANGELOG.md | 2 +- server/src/main/java/org/opensearch/index/get/GetStats.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e20fda7bfdb18..990cb66cafd9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -97,7 +97,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Fix Shallow copy snapshot failures on closed index ([#16868](https://github.com/opensearch-project/OpenSearch/pull/16868)) - Fix multi-value sort for unsigned long ([#16732](https://github.com/opensearch-project/OpenSearch/pull/16732)) - The `phone-search` analyzer no longer emits the tel/sip prefix, international calling code, extension numbers and unformatted input as a token ([#16993](https://github.com/opensearch-project/OpenSearch/pull/16993)) - +- Fix `GetStats` field serialization where `getTime` is used instead of `time` ([#17008](https://github.com/opensearch-project/OpenSearch/pull/17008)) ### Security [Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.18...2.x diff --git a/server/src/main/java/org/opensearch/index/get/GetStats.java b/server/src/main/java/org/opensearch/index/get/GetStats.java index a366014fe228e..0c9e13b1dc42b 100644 --- a/server/src/main/java/org/opensearch/index/get/GetStats.java +++ b/server/src/main/java/org/opensearch/index/get/GetStats.java @@ -155,7 +155,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws static final class Fields { static final String GET = "get"; static final String TOTAL = "total"; - static final String TIME = "getTime"; + static final String TIME = "time"; static final String TIME_IN_MILLIS = "time_in_millis"; static final String EXISTS_TOTAL = "exists_total"; static final String EXISTS_TIME = "exists_time"; From 1bb5cc39d349ce1f4ad8ff6f3deaede6d3afe69f Mon Sep 17 00:00:00 2001 From: hye-on Date: Mon, 13 Jan 2025 22:13:56 +0900 Subject: [PATCH 02/11] Update PR number in changelog Signed-off-by: hye-on --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 990cb66cafd9e..d16f751057ef9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -97,7 +97,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Fix Shallow copy snapshot failures on closed index ([#16868](https://github.com/opensearch-project/OpenSearch/pull/16868)) - Fix multi-value sort for unsigned long ([#16732](https://github.com/opensearch-project/OpenSearch/pull/16732)) - The `phone-search` analyzer no longer emits the tel/sip prefix, international calling code, extension numbers and unformatted input as a token ([#16993](https://github.com/opensearch-project/OpenSearch/pull/16993)) -- Fix `GetStats` field serialization where `getTime` is used instead of `time` ([#17008](https://github.com/opensearch-project/OpenSearch/pull/17008)) +- Fix `GetStats` field serialization where `getTime` is used instead of `time` ([#17008](https://github.com/opensearch-project/OpenSearch/pull/17009)) ### Security [Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.18...2.x From d675a0203b6d16bff2af994cc279fea9effa0c2e Mon Sep 17 00:00:00 2001 From: hye-on Date: Tue, 14 Jan 2025 11:16:05 +0900 Subject: [PATCH 03/11] Deprecate getTime field and add time field in GetStats for backward compatibility Signed-off-by: hye-on --- CHANGELOG.md | 3 ++- server/src/main/java/org/opensearch/index/get/GetStats.java | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d16f751057ef9..6b169af667b73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Changes to support IP field in star tree indexing([#16641](https://github.com/opensearch-project/OpenSearch/pull/16641/)) - Support object fields in star-tree index([#16728](https://github.com/opensearch-project/OpenSearch/pull/16728/)) - Support searching from doc_value using termQueryCaseInsensitive/termQuery in flat_object/keyword field([#16974](https://github.com/opensearch-project/OpenSearch/pull/16974/)) +- Added a new `time` field to replace the deprecated `getTime` field in `GetStats`. ([#17009](https://github.com/opensearch-project/OpenSearch/pull/17009)) ### Dependencies - Bump `com.google.cloud:google-cloud-core-http` from 2.23.0 to 2.47.0 ([#16504](https://github.com/opensearch-project/OpenSearch/pull/16504)) @@ -73,7 +74,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Deprecated - Performing update operation with default pipeline or final pipeline is deprecated ([#16712](https://github.com/opensearch-project/OpenSearch/pull/16712)) - +- Marked `getTime` field as deprecated in favor of the new `time` field. ([#17009](https://github.com/opensearch-project/OpenSearch/pull/17009)) ### Removed ### Fixed diff --git a/server/src/main/java/org/opensearch/index/get/GetStats.java b/server/src/main/java/org/opensearch/index/get/GetStats.java index 0c9e13b1dc42b..2b4e51c063c72 100644 --- a/server/src/main/java/org/opensearch/index/get/GetStats.java +++ b/server/src/main/java/org/opensearch/index/get/GetStats.java @@ -137,6 +137,7 @@ public long current() { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.GET); builder.field(Fields.TOTAL, getCount()); + builder.humanReadableField(Fields.TIME_IN_MILLIS, Fields.GET_TIME, getTime()); builder.humanReadableField(Fields.TIME_IN_MILLIS, Fields.TIME, getTime()); builder.field(Fields.EXISTS_TOTAL, existsCount); builder.humanReadableField(Fields.EXISTS_TIME_IN_MILLIS, Fields.EXISTS_TIME, getExistsTime()); @@ -155,6 +156,11 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws static final class Fields { static final String GET = "get"; static final String TOTAL = "total"; + /** + * Deprecated field name for time. Use {@link #TIME} instead. + */ + @Deprecated + static final String GET_TIME = "getTime"; static final String TIME = "time"; static final String TIME_IN_MILLIS = "time_in_millis"; static final String EXISTS_TOTAL = "exists_total"; From 492767f6b3c45d0dce220db3ebb96d6169850627 Mon Sep 17 00:00:00 2001 From: hye-on Date: Tue, 14 Jan 2025 11:53:00 +0900 Subject: [PATCH 04/11] Add forRemoval flag to getTime field for future removal Signed-off-by: hye-on --- server/src/main/java/org/opensearch/index/get/GetStats.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/index/get/GetStats.java b/server/src/main/java/org/opensearch/index/get/GetStats.java index 2b4e51c063c72..f5a9ea158b360 100644 --- a/server/src/main/java/org/opensearch/index/get/GetStats.java +++ b/server/src/main/java/org/opensearch/index/get/GetStats.java @@ -159,7 +159,7 @@ static final class Fields { /** * Deprecated field name for time. Use {@link #TIME} instead. */ - @Deprecated + @Deprecated(forRemoval = true) static final String GET_TIME = "getTime"; static final String TIME = "time"; static final String TIME_IN_MILLIS = "time_in_millis"; From b18d415da09fbe57a4eb0575b174686caea03edb Mon Sep 17 00:00:00 2001 From: hye-on Date: Wed, 15 Jan 2025 11:53:23 +0900 Subject: [PATCH 05/11] Changed to use field instead of humanReadableField for GET_TIME in JSON response Replaced the use of builder.humanReadableField for the GET_TIME field with builder.field(Fields.GET_TIME, Objects.toString(getTime())). This prevents the duplication of the time_in_millis field. Signed-off-by: hye-on --- server/src/main/java/org/opensearch/index/get/GetStats.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/index/get/GetStats.java b/server/src/main/java/org/opensearch/index/get/GetStats.java index f5a9ea158b360..c0c86ebab578b 100644 --- a/server/src/main/java/org/opensearch/index/get/GetStats.java +++ b/server/src/main/java/org/opensearch/index/get/GetStats.java @@ -41,6 +41,7 @@ import org.opensearch.core.xcontent.XContentBuilder; import java.io.IOException; +import java.util.Objects; /** * Stats for a search get @@ -137,7 +138,7 @@ public long current() { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.GET); builder.field(Fields.TOTAL, getCount()); - builder.humanReadableField(Fields.TIME_IN_MILLIS, Fields.GET_TIME, getTime()); + builder.field( Fields.GET_TIME, Objects.toString(getTime())); builder.humanReadableField(Fields.TIME_IN_MILLIS, Fields.TIME, getTime()); builder.field(Fields.EXISTS_TOTAL, existsCount); builder.humanReadableField(Fields.EXISTS_TIME_IN_MILLIS, Fields.EXISTS_TIME, getExistsTime()); From 98c8a62120aed10abab927ddc64393be69eaf243 Mon Sep 17 00:00:00 2001 From: hye-on Date: Wed, 15 Jan 2025 11:56:28 +0900 Subject: [PATCH 06/11] Add test to validate getTime and time fields in _stats API response getTime and time fields are verified to be included in the _stats API response and correctly aligned. Signed-off-by: hye-on --- .../test/indices.stats/60_time_fields.yml.yml | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/60_time_fields.yml.yml diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/60_time_fields.yml.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/60_time_fields.yml.yml new file mode 100644 index 0000000000000..c229685aa8880 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/60_time_fields.yml.yml @@ -0,0 +1,32 @@ +--- +setup: + - do: + indices.create: + index: test1 + body: + settings: + number_of_shards: 1 + number_of_replicas: 0 + wait_for_active_shards: all + + - do: + index: + index: test1 + id: 1 + body: { "foo": "bar" } + + - do: + indices.refresh: + index: test1 + +--- +"Test _stats API includes both time and getTime metrics with human filter": + - do: + indices.stats: + metric: [ get ] + human: true + + - is_true: _all.primaries.get.time + - is_true: _all.primaries.get.getTime + - match: { _all.primaries.get.time: "0s" } + - match: { _all.primaries.get.getTime: "0s" } From 40ac7289acd4b09614ed92e291dfc75f1f29746b Mon Sep 17 00:00:00 2001 From: hye-on Date: Wed, 15 Jan 2025 21:54:32 +0900 Subject: [PATCH 07/11] Fix formatting in GetStats.java Signed-off-by: hye-on --- server/src/main/java/org/opensearch/index/get/GetStats.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/index/get/GetStats.java b/server/src/main/java/org/opensearch/index/get/GetStats.java index c0c86ebab578b..55f14294d774b 100644 --- a/server/src/main/java/org/opensearch/index/get/GetStats.java +++ b/server/src/main/java/org/opensearch/index/get/GetStats.java @@ -138,7 +138,7 @@ public long current() { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.GET); builder.field(Fields.TOTAL, getCount()); - builder.field( Fields.GET_TIME, Objects.toString(getTime())); + builder.field(Fields.GET_TIME, Objects.toString(getTime())); builder.humanReadableField(Fields.TIME_IN_MILLIS, Fields.TIME, getTime()); builder.field(Fields.EXISTS_TOTAL, existsCount); builder.humanReadableField(Fields.EXISTS_TIME_IN_MILLIS, Fields.EXISTS_TIME, getExistsTime()); From 2b546d242b8aecd40ca838ab8b352f644f4ac63c Mon Sep 17 00:00:00 2001 From: hye-on Date: Thu, 16 Jan 2025 14:23:19 +0900 Subject: [PATCH 08/11] Rename test file to better reflect test purpose Signed-off-by: hye-on --- ...elds.yml.yml => 60_include_both_time_and_gettime_in_stats.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/{60_time_fields.yml.yml => 60_include_both_time_and_gettime_in_stats.yml} (100%) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/60_time_fields.yml.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/60_include_both_time_and_gettime_in_stats.yml similarity index 100% rename from rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/60_time_fields.yml.yml rename to rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/60_include_both_time_and_gettime_in_stats.yml From 3b30e33ed18527294c25d4df006d8529ae57a171 Mon Sep 17 00:00:00 2001 From: hye-on Date: Thu, 16 Jan 2025 22:16:45 +0900 Subject: [PATCH 09/11] Test Add skip version for stats API human filter test under 2.19.99 Signed-off-by: hye-on --- .../60_include_both_time_and_gettime_in_stats.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/60_include_both_time_and_gettime_in_stats.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/60_include_both_time_and_gettime_in_stats.yml index c229685aa8880..d5e3e7554b400 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/60_include_both_time_and_gettime_in_stats.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/60_include_both_time_and_gettime_in_stats.yml @@ -21,6 +21,10 @@ setup: --- "Test _stats API includes both time and getTime metrics with human filter": + - skip: + version: " - 2.19.99" + reason: "this change is added in 3.0.0" + - do: indices.stats: metric: [ get ] From 2754fcb3c6063bda5ac6090aa7754b59dc4054b8 Mon Sep 17 00:00:00 2001 From: hye-on Date: Fri, 17 Jan 2025 10:30:11 +0900 Subject: [PATCH 10/11] Remove unnecessary changelog entries Signed-off-by: hye-on --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b169af667b73..e42a9e368e344 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -98,7 +98,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Fix Shallow copy snapshot failures on closed index ([#16868](https://github.com/opensearch-project/OpenSearch/pull/16868)) - Fix multi-value sort for unsigned long ([#16732](https://github.com/opensearch-project/OpenSearch/pull/16732)) - The `phone-search` analyzer no longer emits the tel/sip prefix, international calling code, extension numbers and unformatted input as a token ([#16993](https://github.com/opensearch-project/OpenSearch/pull/16993)) -- Fix `GetStats` field serialization where `getTime` is used instead of `time` ([#17008](https://github.com/opensearch-project/OpenSearch/pull/17009)) ### Security [Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.18...2.x From 01b790537d33eb7769de4c8991dc2df69f504b89 Mon Sep 17 00:00:00 2001 From: hye-on Date: Fri, 17 Jan 2025 10:34:31 +0900 Subject: [PATCH 11/11] Add a line for styling purposes Signed-off-by: hye-on --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e42a9e368e344..6b8be8f80968f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Deprecated - Performing update operation with default pipeline or final pipeline is deprecated ([#16712](https://github.com/opensearch-project/OpenSearch/pull/16712)) - Marked `getTime` field as deprecated in favor of the new `time` field. ([#17009](https://github.com/opensearch-project/OpenSearch/pull/17009)) + ### Removed ### Fixed @@ -98,6 +99,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Fix Shallow copy snapshot failures on closed index ([#16868](https://github.com/opensearch-project/OpenSearch/pull/16868)) - Fix multi-value sort for unsigned long ([#16732](https://github.com/opensearch-project/OpenSearch/pull/16732)) - The `phone-search` analyzer no longer emits the tel/sip prefix, international calling code, extension numbers and unformatted input as a token ([#16993](https://github.com/opensearch-project/OpenSearch/pull/16993)) + ### Security [Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.18...2.x