Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Fix getTime field name to time in GetStats (#16894) #17047

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add search replica stats to segment replication stats API ([#16678](https://github.com/opensearch-project/OpenSearch/pull/16678))
- Introduce framework for auxiliary transports and an experimental gRPC transport plugin ([#16534](https://github.com/opensearch-project/OpenSearch/pull/16534))
- 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))
Expand Down Expand Up @@ -69,6 +70,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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
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":
- skip:
version: " - 2.19.99"
reason: "this change is added in 3.0.0"

- 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" }
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.opensearch.core.xcontent.XContentBuilder;

import java.io.IOException;
import java.util.Objects;

/**
* Stats for a search get
Expand Down Expand Up @@ -137,6 +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.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());
Expand All @@ -155,7 +157,12 @@ 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";
/**
* Deprecated field name for time. Use {@link #TIME} instead.
*/
@Deprecated(forRemoval = true)
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";
static final String EXISTS_TIME = "exists_time";
Expand Down
Loading