You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat!: bump module to /v5 and promote generated opensearchapi
BREAKING CHANGE: module path is now github.com/opensearch-project/opensearch-go/v5.
The generated API (formerly v5preview/opensearchapi) is now the canonical
opensearchapi package; the hand-written package is removed. Default Router is on
unless OPENSEARCH_GO_ROUTER=false; partial-failure errors report by default
(errmask.Empty). Field renames: Indices->Index, DocumentID->ID, Params now
pointer, BulkResp.Items is []BulkItem. Track 6 of opensearch-project#835.
Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
-[Path segment values are percent-encoded](#path-segment-values-are-percent-encoded)
11
-
-[v5preview/opensearchapi/ package - v5 preview API surface](#v5previewopensearchapi-package---v5-preview-api-surface)
11
+
-[opensearchapi/ package - generated v5 API surface](#opensearchapi-package---generated-v5-api-surface)
12
12
-[Upgrading to >= 4.0.0](#upgrading-to->=-4.0.0)
13
13
-[Import path](#import-path)
14
14
-[Error types](#error-types)
@@ -56,9 +56,9 @@ The recommended call-site pattern is a `for`/`switch` over `opensearchapi.Errors
56
56
57
57
**Where to read more:**
58
58
59
-
-[`v5preview/opensearchapi/README.md`](v5preview/opensearchapi/README.md) - full v5preview usage guide for these errors, including the type-switch pattern and the rationale for preferring it over `errors.As`/`Has`.
60
-
-[`guides/error_handling.md`](guides/error_handling.md) - cross-version best-practices guide with v4 and v5preview examples side-by-side.
-[`opensearchapi/README.md`](opensearchapi/README.md) - full v5 usage guide for these errors, including the type-switch pattern and the rationale for preferring it over `errors.As`/`Has`.
60
+
-[`guides/error_handling.md`](guides/error_handling.md) - cross-version best-practices guide with v4 and v5 examples side-by-side.
**Error types in v4 `opensearchapi/`** (the upgrade source):
64
64
@@ -71,24 +71,24 @@ The recommended call-site pattern is a `for`/`switch` over `opensearchapi.Errors
71
71
|`*MSearchErrors`|`MSearch` when 2+ wrappers fire |`Unwrap() []error` (multi-error contract) |
72
72
|`*MSearchTemplateErrors`|`MSearchTemplate` when 2+ wrappers fire |`Unwrap() []error`|
73
73
74
-
The v5preview surface ports the same model with internal field types regenerated from the [OpenSearch API specification](https://github.com/opensearch-project/opensearch-api-specification) ([see MIGRATING.md](v5preview/opensearchapi/MIGRATING.md#partial-failure-type-renames) for the table).
74
+
The v5 surface ports the same model with internal field types regenerated from the [OpenSearch API specification](https://github.com/opensearch-project/opensearch-api-specification) ([see MIGRATING.md](opensearchapi/MIGRATING.md#partial-failure-type-renames) for the table).
75
75
76
-
### Default Router Injection in v5preview
76
+
### Default Router Injection in v5
77
77
78
-
`v5preview/opensearchapi.NewClient` (and `NewDefaultClient`) now inject [`opensearchtransport.NewDefaultRouter`](https://pkg.go.dev/github.com/opensearch-project/opensearch-go/v4/opensearchtransport#NewDefaultRouter) when the caller leaves `config.Client.Router` nil. The `OPENSEARCH_GO_ROUTER` environment variable acts as an opt-out:
78
+
`opensearchapi.NewClient` (and `NewDefaultClient`) now inject [`opensearchtransport.NewDefaultRouter`](https://pkg.go.dev/github.com/opensearch-project/opensearch-go/v5/opensearchtransport#NewDefaultRouter) when the caller leaves `config.Client.Router` nil. The `OPENSEARCH_GO_ROUTER` environment variable acts as an opt-out:
|`false` / `0`| no Router, no auto-discovery |**injection skipped (Router stays nil)**, no auto-discovery |
85
85
| unparseable | no Router, no auto-discovery | default Router injected, no auto-discovery |
86
86
87
-
Truthy and falsy semantics are preserved end-to-end: a v4 caller running with `OPENSEARCH_GO_ROUTER=true` keeps auto-discovery when migrating to v5preview, and `=false` opts out of both Router injection and auto-discovery. A caller-supplied `DiscoverNodesOnStart` value always wins over the env-var-driven side-effect.
87
+
Truthy and falsy semantics are preserved end-to-end: a v4 caller running with `OPENSEARCH_GO_ROUTER=true` keeps auto-discovery when migrating to v5, and `=false` opts out of both Router injection and auto-discovery. A caller-supplied `DiscoverNodesOnStart` value always wins over the env-var-driven side-effect.
88
88
89
-
v4's `opensearchapi.NewClient`is unchanged: it doesn't auto-inject a Router, so existing v4 code keeps its current behavior.
89
+
v4's `opensearchapi.NewClient`did not auto-inject a Router, so v4 code keeps its original behavior; v5 flips the default so the Router is on unless `OPENSEARCH_GO_ROUTER=false`.
90
90
91
-
For full usage and rationale see [`v5preview/opensearchapi/README.md` Default Router Injection](v5preview/opensearchapi/README.md#default-router-injection).
91
+
For full usage and rationale see [`opensearchapi/README.md` Default Router Injection](opensearchapi/README.md#default-router-injection).
92
92
93
93
### `DiscoverNodes()` blocking semantics
94
94
@@ -133,7 +133,7 @@ type Route interface {
133
133
}
134
134
```
135
135
136
-
External code that implements `Route` (custom routing policies) must add an `OpID() OperationID` method returning the [`OperationID`](https://pkg.go.dev/github.com/opensearch-project/opensearch-go/v4/opensearchtransport#OperationID) for the route -- typically the `Op*` constant matching the route's HTTP method+path. Built-in routes built via `NewRouteMux` are populated automatically; only hand-written `Route` implementations are affected.
136
+
External code that implements `Route` (custom routing policies) must add an `OpID() OperationID` method returning the [`OperationID`](https://pkg.go.dev/github.com/opensearch-project/opensearch-go/v5/opensearchtransport#OperationID) for the route -- typically the `Op*` constant matching the route's HTTP method+path. Built-in routes built via `NewRouteMux` are populated automatically; only hand-written `Route` implementations are affected.
This change is invisible to almost all callers: the typed `Req` structs that the client consumes (e.g. `opensearchapi.SearchReq`, the v5-preview `opensearchapi.IndexReq`) already implement the new signature. Only code that defines a custom type satisfying `opensearch.Request` is affected. If you maintain such a type, add a `method string` parameter and forward it to your underlying `http.NewRequest` call (or `opensearch.BuildRequest`).
171
+
This change is invisible to almost all callers: the typed `Req` structs that the client consumes (e.g. `opensearchapi.SearchReq`, `opensearchapi.IndexReq`) already implement the new signature. Only code that defines a custom type satisfying `opensearch.Request` is affected. If you maintain such a type, add a `method string` parameter and forward it to your underlying `http.NewRequest` call (or `opensearch.BuildRequest`).
172
172
173
173
### Path segment values are percent-encoded
174
174
@@ -188,19 +188,19 @@ If your code intentionally passes percent-encoded values, decode them with `url.
### `v5preview/opensearchapi/` package — v5 preview API surface
191
+
### `opensearchapi/` package - generated v5 API surface
192
192
193
-
This release introduces a new `v5preview/opensearchapi/` package alongside the existing top-level `opensearchapi/` package. The new package is the **preview of the v5 API in the v4 branch** and is generated from the [OpenSearch API specification](https://github.com/opensearch-project/opensearch-api-specification) by `cmd/osgen`. It deliberately reuses the package name `opensearchapi` so that callers who migrate during the v4 branch only need to change the import path at v5 release time -- every reference in code (e.g. `opensearchapi.IndexReq`, `opensearchapi.NewClient`) stays the same.
193
+
The v5 `opensearchapi/` package is generated from the [OpenSearch API specification](https://github.com/opensearch-project/opensearch-api-specification) by `cmd/osgen`, replacing the hand-written `opensearchapi/` package that shipped through v4. The same surface was distributed during the v4 branch as an early-access preview package for early adopters; it deliberately reused the package name `opensearchapi` so that callers who migrated during v4 only needed to change the import path at v5 release time -- every reference in code (e.g. `opensearchapi.IndexReq`, `opensearchapi.NewClient`) stays the same.
194
194
195
195
**Migration Considerations:**
196
196
197
-
- Migrating to `v5preview/opensearchapi/`in v4 gives you the v5 surface ahead of v5 release. The trade-off at v5 release time is a single edit per consuming file: change the import path from `/v4/v5preview/opensearchapi` to `/v5/opensearchapi`. Package qualifiers do not change.
198
-
-Staying on the top-level `opensearchapi/` package is fine through the rest of v4. At v5, the hand-written `opensearchapi/` is removed; the only forward path is the code-generated API surface (closely matches the existing hand-written ergonomics).
197
+
- Migrating from the hand-written v4 `opensearchapi/`to the v5 generated surface is a single import-path edit per consuming file: change the module path from `/v4/opensearchapi` to `/v5/opensearchapi`. Package qualifiers do not change. (Early adopters of the v4 preview package likewise change their import to `/v5/opensearchapi`.)
198
+
- At v5, the hand-written `opensearchapi/` is removed; the only forward path is the code-generated API surface (closely matches the existing hand-written ergonomics).
- Optional `Params` are `*Params` pointer fields (nil-safe; pass `&opensearchapi.IndexParams{...}` to set).
211
211
- Optional boolean query parameters are `*bool` so a deliberate `false` can be sent over the wire.
212
212
- Multi-index `Req` types use `Index []string` (the spec spelling); v4's hand-written `Indices` is renamed.
213
-
- Plugin APIs (k-NN, ML, Security, ISM, etc.) live in `v5preview/opensearchapi/plugins/`.
213
+
- Plugin APIs (k-NN, ML, Security, ISM, etc.) live in `opensearchapi/plugins/`.
214
214
215
-
For the full v4 -> v5preview surface delta and the optional forward-compatible `replace` directive, see [`v5preview/opensearchapi/MIGRATING.md`](v5preview/opensearchapi/MIGRATING.md). For everyday usage (errors, routing, response handling) see [`v5preview/opensearchapi/README.md`](v5preview/opensearchapi/README.md).
215
+
For the full v4 -> v5 surface delta and the optional forward-compatible `replace` directive, see [`opensearchapi/MIGRATING.md`](opensearchapi/MIGRATING.md). For everyday usage (errors, routing, response handling) see [`opensearchapi/README.md`](opensearchapi/README.md).
The `signer/awsv2` package (which already used AWS SDK v2) remains available at `github.com/opensearch-project/opensearch-go/v4/signer/awsv2` with the same API.
351
+
The `signer/awsv2` package (which already used AWS SDK v2) remains available at `github.com/opensearch-project/opensearch-go/v5/signer/awsv2` with the same API.
352
352
353
353
### Typed Failure Arrays in By-Query and Reindex Responses
0 commit comments