Skip to content

Commit 7190bfd

Browse files
committed
docs(guides): link guides to their runnable samples; fix usage-json TOC
Guides and _samples were coupled only by filename prefix, with no hyperlink between them. Add a "Runnable example" pointer near the top of each guide that has a matching sample (8 guides), completing the bidirectional discoverability started in the samples' header pointers. The indexing-data_streams guide points to the singular-named indexing-data_stream.go sample. Also fix a pre-existing stale entry in usage-json.md's table of contents: "Using Do for Typed Responses" -> "Using Execute for Typed Responses", matching the actual section heading. Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
1 parent 71f4fe5 commit 7190bfd

8 files changed

Lines changed: 17 additions & 1 deletion

guides/indexing-advanced_index_actions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Advanced Index Actions
22

3+
> **Runnable example:** [`_samples/indexing-advanced_index_actions.go`](../_samples/indexing-advanced_index_actions.go)
4+
35
> **Note:** Examples in this guide use raw JSON strings for request bodies because the `opensearchapi` package accepts `io.Reader`. When building bodies from user-supplied values, always use `opensearchutil.NewJSONReader` with a Go struct or map instead of string interpolation. See [Security](config-security.md#request-body-construction) for details.
46
57
In this guide, we will look at some advanced index actions that are not covered in the [Index Lifecycle](indexing-index_lifecycle.md) guide.

guides/indexing-bulk.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Bulk
22

3+
> **Runnable example:** [`_samples/indexing-bulk.go`](../_samples/indexing-bulk.go)
4+
35
In this guide, you'll learn how to use the OpenSearch Golang Client API to perform bulk operations. You'll learn how to index, update, and delete multiple documents in a single request.
46

57
> **Surface note**: the `bulk` API returns `BulkResp.Items` as `[]BulkItem` -- a struct with named fields per operation (`Index`, `Create`, `Update`, `Delete`), each a `*BulkRespItem`. `BulkRespItem.ID` is a `*string`, so deref before formatting. Multi-index `Req` types use `Index []string` (e.g. `IndicesDeleteReq.Index`); `BulkReq.Index` (singular, the default per-request `_index`) is unchanged. See the [Handling errors](#handling-errors) section for an example.

guides/indexing-data_streams.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Data Streams API
22

3+
> **Runnable example:** [`_samples/indexing-data_stream.go`](../_samples/indexing-data_stream.go)
4+
35
> **Note:** Examples in this guide use raw JSON strings for request bodies because the `opensearchapi` package accepts `io.Reader`. When building bodies from user-supplied values, always use `opensearchutil.NewJSONReader` with a Go struct or map instead of string interpolation. See [Security](config-security.md#request-body-construction) for details.
46
57
## Setup

guides/indexing-document_lifecycle.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Document Lifecycle
22

3+
> **Runnable example:** [`_samples/indexing-document_lifecycle.go`](../_samples/indexing-document_lifecycle.go)
4+
35
> **Note:** Examples in this guide use raw JSON strings for request bodies because the `opensearchapi` package accepts `io.Reader`. When building bodies from user-supplied values, always use `opensearchutil.NewJSONReader` with a Go struct or map instead of string interpolation. See [Security](config-security.md#request-body-construction) for details.
46
57
This guide covers OpenSearch Golang Client API actions for Document Lifecycle. You'll learn how to create, read, update, and delete documents in your OpenSearch cluster. Whether you're new to OpenSearch or an experienced user, this guide provides the information you need to manage your document lifecycle effectively.

guides/indexing-index_lifecycle.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Index Lifecycle
22

3+
> **Runnable example:** [`_samples/indexing-index_lifecycle.go`](../_samples/indexing-index_lifecycle.go)
4+
35
> **Note:** Examples in this guide use raw JSON strings for request bodies because the `opensearchapi` package accepts `io.Reader`. When building bodies from user-supplied values, always use `opensearchutil.NewJSONReader` with a Go struct or map instead of string interpolation. See [Security](config-security.md#request-body-construction) for details.
46
57
This guide covers OpenSearch Golang Client API actions for Index Lifecycle. You'll learn how to create, get, update settings, update mapping, and delete indices in your OpenSearch cluster. We will also leverage index templates to create default settings and mappings for indices of certain patterns.

guides/usage-json.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
- [Making Raw JSON REST Requests](#making-raw-json-rest-requests)
22
- [Setup](#setup)
3-
- [Using Do for Typed Responses](#using-do-for-typed-responses)
3+
- [Using Execute for Typed Responses](#using-execute-for-typed-responses)
44
- [GET](#get)
55
- [PUT](#put)
66
- [POST](#post)
77
- [DELETE](#delete)
88

99
# Making Raw JSON REST Requests
1010

11+
> **Runnable example:** [`_samples/usage-json.go`](../_samples/usage-json.go)
12+
1113
The OpenSearch client implements many high-level REST DSLs that invoke OpenSearch APIs. However you may find yourself in a situation that requires you to invoke an API that is not supported by the client. Use `client.Perform` to do so.
1214

1315
## Setup

guides/usage-search.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Search
22

3+
> **Runnable example:** [`_samples/usage-search.go`](../_samples/usage-search.go)
4+
35
> **Note:** Examples in this guide use `opensearchutil.NewJSONReader` for request bodies that contain dynamic values. For static query strings, raw JSON is acceptable. When building bodies from user-supplied values, always use structured serialization. See [Security](config-security.md#request-body-construction) for details.
46
57
OpenSearch provides a powerful search API that allows you to search for documents in an index. The search API supports a number of parameters that allow you to customize the search operation. In this guide, we will explore the search API and its parameters.

guides/usage-tasks.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Tasks
22

3+
> **Runnable example:** [`_samples/usage-tasks.go`](../_samples/usage-tasks.go)
4+
35
> **Note:** Examples in this guide use `opensearchutil.NewJSONReader` for request bodies that contain dynamic values. See [Security](config-security.md#request-body-construction) for details on safe body construction.
46
57
In this guide, you'll learn how to use the OpenSearch Golang Client API to manage asynchronous tasks. You'll learn how to submit long-running operations asynchronously, poll for their completion, and inspect task status.

0 commit comments

Comments
 (0)