Skip to content

Commit 6949c2f

Browse files
committed
Fix cat APIs compatibility with OpenSearch 3.2.0+
OpenSearch 3.2.0 introduced new fields in the cat APIs (indices, nodes, shards) that were being dropped during JSON marshalling/unmarshalling. This resulted in test failures when comparing raw JSON with parsed JSON. Added missing fields to CatIndexResp, CatNodesItemResp, and CatShardResp structs: - LastIndexRequestTimestamp and LastIndexRequestTimestampString in indices API - SearchStartreeQueryCurrent, SearchStartreeQueryTime, SearchStartreeQueryTotal in search stats - PrimaryStartreeQueryCurrent, PrimaryStartreeQueryTime, PrimaryStartreeQueryTotal in primary search stats (indices only) These fields are always present in OpenSearch 3.2.0+ cat API responses and should be preserved without omitempty tags since they contain legitimate zero values. This complements the similar fixes made to the nodes stats and indices stats APIs and ensures full cat API compatibility with OpenSearch 3.2.0+. Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
1 parent 271bc86 commit 6949c2f

4 files changed

Lines changed: 15 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1717
- Fix nodes API compatibility with OpenSearch 3.1.0+ by adding phase_results_processors field
1818
- Fix nodes stats API compatibility with OpenSearch 3.2.0+ by adding max_last_index_request_timestamp and startree query fields
1919
- Fix indices stats API compatibility with OpenSearch 3.2.0+ by adding max_last_index_request_timestamp and startree query fields
20+
- Fix cat APIs compatibility with OpenSearch 3.2.0+ by adding indexing timestamp and startree query fields
2021

2122
### Security
2223

opensearchapi/api_cat-indices.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ type CatIndexResp struct {
156156
PrimarySearchConcurrentQueryTotal *int `json:"pri.search.concurrent_query_total,string"`
157157
SearchConcurrentAvgSliceCount *string `json:"search.concurrent_avg_slice_count"`
158158
PrimarySearchConcurrentAvgSliceCount *string `json:"pri.search.concurrent_avg_slice_count"`
159+
SearchStartreeQueryCurrent *int `json:"search.startree_query_current,string"` // Available in OpenSearch 3.2.0+
160+
PrimaryStartreeQueryCurrent *int `json:"pri.startree.query_current,string"` // Available in OpenSearch 3.2.0+
161+
SearchStartreeQueryTime *string `json:"search.startree_query_time"` // Available in OpenSearch 3.2.0+
162+
PrimaryStartreeQueryTime *string `json:"pri.startree.query_time"` // Available in OpenSearch 3.2.0+
163+
SearchStartreeQueryTotal *string `json:"search.startree_query_total"` // Available in OpenSearch 3.2.0+
164+
PrimaryStartreeQueryTotal *string `json:"pri.startree.query_total"` // Available in OpenSearch 3.2.0+
159165
SearchScrollCurrent *int `json:"search.scroll_current,string"`
160166
PrimarySearchScrollCurrent *int `json:"pri.search.scroll_current,string"`
161167
SearchScrollTime *string `json:"search.scroll_time"`
@@ -193,6 +199,8 @@ type CatIndexResp struct {
193199
MemoryTotal string `json:"memory.total"`
194200
PrimaryMemoryTotal string `json:"pri.memory.total"`
195201
SearchThrottled bool `json:"search.throttled,string"`
202+
LastIndexRequestTimestamp *string `json:"last_index_request_timestamp"` // Available in OpenSearch 3.2.0+
203+
LastIndexRequestTimestampString *string `json:"last_index_request_timestamp_string"` // Available in OpenSearch 3.2.0+
196204
}
197205

198206
// Inspect returns the Inspect type containing the raw *opensearch.Response

opensearchapi/api_cat-nodes.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ type CatNodesItemResp struct {
122122
SearchConcurrentQueryTime *string `json:"search.concurrent_query_time"`
123123
SearchConcurrentQueryTotal *int `json:"search.concurrent_query_total,string"`
124124
SearchConcurrentAvgSliceCount *string `json:"search.concurrent_avg_slice_count"`
125+
SearchStartreeQueryCurrent *int `json:"search.startree_query_current,string"` // Available in OpenSearch 3.2.0+
126+
SearchStartreeQueryTime *string `json:"search.startree_query_time"` // Available in OpenSearch 3.2.0+
127+
SearchStartreeQueryTotal *int `json:"search.startree_query_total,string"` // Available in OpenSearch 3.2.0+
125128
SearchScrollCurrent *int `json:"search.scroll_current,string"`
126129
SearchScrollTime *string `json:"search.scroll_time"`
127130
SearchScrollTotal *int `json:"search.scroll_total,string"`

opensearchapi/api_cat-shards.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ type CatShardResp struct {
106106
SearchConcurrentQueryTime *string `json:"search.concurrent_query_time"`
107107
SearchConcurrentQueryTotal *int `json:"search.concurrent_query_total,string"`
108108
SearchConcurrentAvgSliceCount *string `json:"search.concurrent_avg_slice_count"`
109+
SearchStartreeQueryCurrent *int `json:"search.startree_query_current,string"` // Available in OpenSearch 3.2.0+
110+
SearchStartreeQueryTime *string `json:"search.startree_query_time"` // Available in OpenSearch 3.2.0+
111+
SearchStartreeQueryTotal *int `json:"search.startree_query_total,string"` // Available in OpenSearch 3.2.0+
109112
SearchScrollCurrent *int `json:"search.scroll_current,string"`
110113
SearchScrollTime *string `json:"search.scroll_time"`
111114
SearchScrollTotal *int `json:"search.scroll_total,string"`

0 commit comments

Comments
 (0)