github opensearch-project/opensearch-go v5.0.3

3 hours ago

opensearch-go v5.0.3

UPGRADE NOTE - v5.0.3 turns on periodic node discovery by default.

  • DiscoverNodesInterval defaults to 30s when a router is in use, and that includes the default router. Under the old 0 default the discovery loop never ran. The client missed nodes added after startup, and a node flagged after a failed request stayed out of shard-aware routing until restart, because only that loop refreshes /_cat/shards.
  • To keep periodic discovery off, set DiscoverNodesInterval to a negative value. Without a router, 0 still turns it off.

Before/after is in UPGRADING_V5.md.

v5.0.3 adds an optional compress module with klauspost codecs and a typed builder for _msearch bodies. It also fixes snapshot responses that failed to decode, fills in the aggregation fields the generator was dropping, and extends the osapilint v4 -> v5 migration.

Requires Go 1.26.0 or later.

Full Changelog: v5.0.2...v5.0.3


What's new

  • The new compress module (github.com/opensearch-project/opensearch-go/compress/v5) provides Gzip, Deflate and Snappy. Each returns an opensearchtransport.Compressor backed by github.com/klauspost/compress. It ships as a separate module so klauspost stays out of the client's dependency graph, and no klauspost type appears in its API. Gzip and Deflate reject an invalid level at construction, and compress.DefaultLevel picks the codec's own default (#1199)
  • opensearchapi.BuildMSearchBody builds the newline-delimited body for MSearchReq.Body from typed SearchBody values, so you no longer hand-encode a header line and a body line per search. A sub-search with no Indices runs against the indices on the MSearchReq, and a nil Body becomes an empty search (#1214)

Fixes

  • fix(opensearchapi): client.Snapshot.Get and client.Snapshot.Create failed with failed to json unmarshal body on an HTTP 200 whenever a snapshot carried a shard failure. The server writes shard_id as an integer while the spec declares a string. SnapshotShardFailure.ShardID stays a *string and now accepts an integer, stored as its decimal string (opensearch-api-specification#1263). By @xluo-aws in #1198
  • fix(osgen): CommonAggregationsAggregationContainer now has its aggregation fields. When an allOf member is a oneOf or anyOf, the generator merges every branch's properties as optional fields. Reported in #1190. By @MohammedAlkindi in #1197
  • fix(osapilint): the v4 -> v5 hop migrates the IndexTemplate, ComponentTemplate, Template, Script and DataStream sub-clients and reports plugins/security and plugins/ism code, which it used to skip with exit 0. It also completes on v4 code that sets Pretty, H, V or the timeout params, where it used to abort with an osapilint bug error. Reported by @Jakob3xD in #1174. By @ryanyuan in #1213
  • docs: godoc and guide defaults now match the code. MaxRetries is 6, not 3. HealthCheckTimeout is 5s, not 3s. HealthCheckMaxRetries is 6, not 3. HealthCheckJitter is 0.1, not 0.2 (#1211)

Dependencies

  • Bump github.com/aws/aws-sdk-go-v2 to 1.47.3 and aws-sdk-go-v2/config to 1.33.9 (#1206, #1207)
  • Bump golang.org/x/sync to 0.24.0, golang.org/x/mod to 0.42.0 and, in cmd/osapilint, golang.org/x/tools (#1200, #1208, #1209, #1210)

See CHANGELOG.md for the full list.

Contributors

Thanks to everyone who contributed to this release: @ryanyuan, @sean-, @MohammedAlkindi, and @xluo-aws.

New Contributors

Don't miss a new opensearch-go release

NewReleases is sending notifications on new releases.