opensearch-sugar 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.agents/skills/diataxis/SKILL.md +142 -0
- data/.agents/skills/diataxis/references/examples.md +420 -0
- data/.agents/skills/diataxis/references/explanation-template.md +96 -0
- data/.agents/skills/diataxis/references/framework.md +400 -0
- data/.agents/skills/diataxis/references/how-to-guide-template.md +105 -0
- data/.agents/skills/diataxis/references/reference-template.md +110 -0
- data/.agents/skills/diataxis/references/tutorial-template.md +101 -0
- data/.agents/skills/diataxis/scripts/generate_index.py +139 -0
- data/.rspec +3 -0
- data/.standard.yml +3 -0
- data/AGENTS.md +120 -0
- data/CHANGELOG.md +5 -0
- data/Dockerfile.opensearch +4 -0
- data/Increase_Coverage.md +311 -0
- data/README.md +143 -0
- data/Rakefile +27 -0
- data/Steepfile +23 -0
- data/adrs/ADR-000-template.md +87 -0
- data/adrs/ADR-001-simpledelegator-for-client.md +138 -0
- data/adrs/ADR-002-facade-pattern-for-index.md +126 -0
- data/adrs/ADR-003-repository-pattern-for-models.md +148 -0
- data/adrs/ADR-004-integration-tests-no-mocking.md +91 -0
- data/adrs/ADR-005-exceptions-over-result-objects.md +107 -0
- data/adrs/ADR-006-ssl-on-by-default.md +95 -0
- data/adrs/ADR-007-selective-sugar-surface.md +118 -0
- data/adrs/ADR-008-integration-test-design.md +178 -0
- data/compose.yml +2 -0
- data/compose_opensearch.yml +31 -0
- data/docs/HOWTO.md +844 -0
- data/docs/REFERENCE.md +725 -0
- data/docs/TUTORIAL.md +327 -0
- data/docs/alias-api-design-notes.md +119 -0
- data/lib/opensearch/sugar/client.rb +300 -0
- data/lib/opensearch/sugar/index/include/utilities.rb +6 -0
- data/lib/opensearch/sugar/index.rb +339 -0
- data/lib/opensearch/sugar/models.rb +209 -0
- data/lib/opensearch/sugar/version.rb +8 -0
- data/lib/opensearch/sugar.rb +61 -0
- data/old_docs/DELEGATED_METHODS_ANALYSIS.md +361 -0
- data/old_docs/EXPLANATION.md +685 -0
- data/old_docs/README.md +155 -0
- data/old_docs/docs/CLI-PROPOSAL.md +257 -0
- data/old_docs/docs/HOWTO.md +798 -0
- data/old_docs/docs/REFERENCE.md +901 -0
- data/old_docs/docs/TUTORIAL.md +493 -0
- data/sig/opensearch/sugar.rbs +162 -0
- metadata +240 -0
data/old_docs/README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# OpenSearch::Sugar Documentation
|
|
2
|
+
|
|
3
|
+
*(Documentation written by GitHub Copilot, powered by Claude Sonnet 4.5)*
|
|
4
|
+
|
|
5
|
+
Welcome to the OpenSearch::Sugar documentation! This documentation is organized using the [DiΓ‘taxis Framework](https://diataxis.fr/), which structures technical documentation into four distinct types based on the user's needs.
|
|
6
|
+
|
|
7
|
+
## How to Use This Documentation
|
|
8
|
+
|
|
9
|
+
### π [Tutorial](TUTORIAL.md) - I want to learn
|
|
10
|
+
|
|
11
|
+
**Start here if you're new to OpenSearch::Sugar.**
|
|
12
|
+
|
|
13
|
+
A hands-on, step-by-step guide that walks you through building a complete searchable book catalog application. By the end, you'll understand the core concepts and be able to build your own OpenSearch applications.
|
|
14
|
+
|
|
15
|
+
**Best for:**
|
|
16
|
+
- First-time users
|
|
17
|
+
- Learning the basics
|
|
18
|
+
- Understanding how everything fits together
|
|
19
|
+
|
|
20
|
+
**Time:** ~30 minutes
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
### π§ [How-to Guides](HOWTO.md) - I want to solve a problem
|
|
25
|
+
|
|
26
|
+
**Use this when you need to accomplish a specific task.**
|
|
27
|
+
|
|
28
|
+
Practical recipes for common tasks like creating indexes, analyzing text, managing aliases, working with ML models, and handling errors. Each guide is focused on solving one specific problem.
|
|
29
|
+
|
|
30
|
+
**Best for:**
|
|
31
|
+
- Solving specific problems
|
|
32
|
+
- Quick reference during development
|
|
33
|
+
- Finding examples for common tasks
|
|
34
|
+
|
|
35
|
+
**Format:** Copy-paste ready code examples
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### π [API Reference](REFERENCE.md) - I need technical details
|
|
40
|
+
|
|
41
|
+
**Use this when you need complete, accurate information about the API.**
|
|
42
|
+
|
|
43
|
+
Complete technical reference for all classes, methods, parameters, return values, and exceptions. Includes type signatures and links to related OpenSearch documentation.
|
|
44
|
+
|
|
45
|
+
**Best for:**
|
|
46
|
+
- Looking up exact method signatures
|
|
47
|
+
- Understanding all available options
|
|
48
|
+
- Finding all methods in a class
|
|
49
|
+
- Type checking and IDE autocomplete
|
|
50
|
+
|
|
51
|
+
**Format:** Structured reference documentation
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### π‘ [Explanation](EXPLANATION.md) - I want to understand
|
|
56
|
+
|
|
57
|
+
**Read this to understand the "why" behind the design.**
|
|
58
|
+
|
|
59
|
+
Conceptual discussions about OpenSearch::Sugar's architecture, design decisions, text analysis, index management, ML models, and best practices. Helps you understand how to use the gem effectively.
|
|
60
|
+
|
|
61
|
+
**Best for:**
|
|
62
|
+
- Understanding design decisions
|
|
63
|
+
- Learning best practices
|
|
64
|
+
- Making architectural decisions
|
|
65
|
+
- Optimizing performance
|
|
66
|
+
|
|
67
|
+
**Format:** Discussion and explanation
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Quick Navigation
|
|
72
|
+
|
|
73
|
+
### By Experience Level
|
|
74
|
+
|
|
75
|
+
**Beginner:**
|
|
76
|
+
1. Start with the [Tutorial](TUTORIAL.md)
|
|
77
|
+
2. Browse [How-to Guides](HOWTO.md) for common tasks
|
|
78
|
+
3. Read [Explanation](EXPLANATION.md) when you want deeper understanding
|
|
79
|
+
|
|
80
|
+
**Intermediate:**
|
|
81
|
+
1. Use [How-to Guides](HOWTO.md) for specific problems
|
|
82
|
+
2. Reference [API Reference](REFERENCE.md) for exact details
|
|
83
|
+
3. Read [Explanation](EXPLANATION.md) for best practices
|
|
84
|
+
|
|
85
|
+
**Advanced:**
|
|
86
|
+
1. Use [API Reference](REFERENCE.md) as primary resource
|
|
87
|
+
2. Refer to [How-to Guides](HOWTO.md) for unusual cases
|
|
88
|
+
3. Read [Explanation](EXPLANATION.md) for optimization strategies
|
|
89
|
+
|
|
90
|
+
### By Task
|
|
91
|
+
|
|
92
|
+
| I want to... | Document |
|
|
93
|
+
|-------------|----------|
|
|
94
|
+
| Build my first application | [Tutorial](TUTORIAL.md) |
|
|
95
|
+
| Create an index | [How-to Guides](HOWTO.md#how-to-create-an-index) |
|
|
96
|
+
| Configure analyzers | [Tutorial](TUTORIAL.md#step-4-configure-custom-analyzers) |
|
|
97
|
+
| Understand text analysis | [Explanation](EXPLANATION.md#understanding-text-analysis) |
|
|
98
|
+
| Look up a method | [API Reference](REFERENCE.md) |
|
|
99
|
+
| Handle errors | [How-to Guides](HOWTO.md#error-handling) |
|
|
100
|
+
| Work with ML models | [How-to Guides](HOWTO.md#ml-models) |
|
|
101
|
+
| Optimize performance | [Explanation](EXPLANATION.md#performance-considerations) |
|
|
102
|
+
| Learn best practices | [Explanation](EXPLANATION.md#security-and-best-practices) |
|
|
103
|
+
|
|
104
|
+
### By Topic
|
|
105
|
+
|
|
106
|
+
| Topic | Documents |
|
|
107
|
+
|-------|-----------|
|
|
108
|
+
| **Getting Started** | [Tutorial](TUTORIAL.md), [Quick Start in main README](../README.md#quick-start-tutorial) |
|
|
109
|
+
| **Index Management** | [How-to: Index Management](HOWTO.md#index-management), [Explanation: Index Concepts](EXPLANATION.md#index-management-concepts) |
|
|
110
|
+
| **Text Analysis** | [Tutorial: Analyzers](TUTORIAL.md#step-4-configure-custom-analyzers), [Explanation: Understanding Text Analysis](EXPLANATION.md#understanding-text-analysis) |
|
|
111
|
+
| **Searching** | [How-to: Search and Analysis](HOWTO.md#search-and-analysis), [Tutorial: Search](TUTORIAL.md#step-8-search-your-catalog) |
|
|
112
|
+
| **ML Models** | [How-to: ML Models](HOWTO.md#ml-models), [Explanation: ML Models](EXPLANATION.md#ml-models-and-embeddings), [API: Models](REFERENCE.md#class-opensearchsugarmodels) |
|
|
113
|
+
| **Configuration** | [How-to: Connection](HOWTO.md#connection-and-configuration), [API: Client](REFERENCE.md#class-opensearchsugarclient) |
|
|
114
|
+
| **Error Handling** | [How-to: Errors](HOWTO.md#error-handling), [API: Errors](REFERENCE.md#error-classes) |
|
|
115
|
+
| **Performance** | [Explanation: Performance](EXPLANATION.md#performance-considerations) |
|
|
116
|
+
| **Security** | [Explanation: Security](EXPLANATION.md#security-and-best-practices) |
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Contributing to Documentation
|
|
121
|
+
|
|
122
|
+
Found an error or want to improve the documentation? Contributions are welcome!
|
|
123
|
+
|
|
124
|
+
When contributing documentation:
|
|
125
|
+
- Follow the DiΓ‘taxis framework structure
|
|
126
|
+
- Use clear, simple language
|
|
127
|
+
- Include working code examples
|
|
128
|
+
- Link to relevant OpenSearch documentation
|
|
129
|
+
- Test all code examples
|
|
130
|
+
|
|
131
|
+
See [CONTRIBUTING.md](../CONTRIBUTING.md) for details.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## External Resources
|
|
136
|
+
|
|
137
|
+
- [OpenSearch Official Documentation](https://opensearch.org/docs/latest/)
|
|
138
|
+
- [OpenSearch Ruby Client](https://github.com/opensearch-project/opensearch-ruby)
|
|
139
|
+
- [OpenSearch API Reference](https://opensearch.org/docs/latest/api-reference/)
|
|
140
|
+
- [DiΓ‘taxis Framework](https://diataxis.fr/) - Documentation structure we follow
|
|
141
|
+
- [Main Project README](../README.md)
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Document Status
|
|
146
|
+
|
|
147
|
+
| Document | Status | Last Updated |
|
|
148
|
+
|----------|--------|--------------|
|
|
149
|
+
| [Tutorial](TUTORIAL.md) | β
Complete | 2026-03-13 |
|
|
150
|
+
| [How-to Guides](HOWTO.md) | β
Complete | 2026-03-13 |
|
|
151
|
+
| [API Reference](REFERENCE.md) | β
Complete | 2026-03-13 |
|
|
152
|
+
| [Explanation](EXPLANATION.md) | β
Complete | 2026-03-13 |
|
|
153
|
+
|
|
154
|
+
**Version:** v0.1.0
|
|
155
|
+
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# CLI Interface Proposal for opensearch-sugar
|
|
2
|
+
|
|
3
|
+
## Summary and Recommendation
|
|
4
|
+
|
|
5
|
+
A thin CLI wrapper around `opensearch-sugar` would be genuinely useful for a specific set of
|
|
6
|
+
operations: deploying and managing ML models, manipulating aliases, and performing bulk indexing
|
|
7
|
+
tasks that operators currently script by hand. These are workflows where a command-line interface
|
|
8
|
+
meaningfully reduces friction compared to writing one-off Ruby scripts.
|
|
9
|
+
|
|
10
|
+
**Recommendation: build it, but scope it narrowly.**
|
|
11
|
+
|
|
12
|
+
The argument for building: ML model lifecycle management (register, deploy, undeploy, delete) is
|
|
13
|
+
operationally complex, configuration-driven, and fundamentally a DevOps task rather than a
|
|
14
|
+
programming task. A CLI surfaces that workflow cleanly and makes it scriptable without requiring
|
|
15
|
+
the operator to write Ruby. Alias management follows the same logic β it is a routine deployment
|
|
16
|
+
operation, not something that belongs in application code.
|
|
17
|
+
|
|
18
|
+
The argument against overbuilding: OpenSearch ships a full-featured Dashboard UI. Recreating
|
|
19
|
+
index browse, search, or mapping visualisation in a CLI produces a worse experience than what
|
|
20
|
+
already exists, at real maintenance cost. The CLI should do things the Dashboard does poorly
|
|
21
|
+
(batch operations, scripting, ML model management) and deliberately omit things the Dashboard
|
|
22
|
+
does well (ad-hoc querying, visual mapping inspection, cluster monitoring).
|
|
23
|
+
|
|
24
|
+
The maintenance cost of the proposed scope is low. The command surface is small, `dry-cli`
|
|
25
|
+
handles argument parsing and help generation, and the implementation is almost entirely
|
|
26
|
+
delegation to the existing Sugar API β adding a new CLI command should take an hour, not a day.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Potential Audiences
|
|
31
|
+
|
|
32
|
+
### Infrastructure / platform engineers
|
|
33
|
+
Operators who manage OpenSearch clusters for application teams. They need to automate index
|
|
34
|
+
creation, alias cutover (zero-downtime re-indexing), and ML model deployment as part of CI/CD
|
|
35
|
+
pipelines or runbooks. They are comfortable with shell scripting and expect commands to be
|
|
36
|
+
composable and scriptable (`--format json`, exit codes, stdin/stdout).
|
|
37
|
+
|
|
38
|
+
### Data engineers and ML practitioners
|
|
39
|
+
People who register and tune embedding models via ML Commons. The registration/deploy/undeploy
|
|
40
|
+
lifecycle is tedious via the raw REST API; a CLI with clear status feedback and idempotent
|
|
41
|
+
commands reduces the chance of leaving a cluster in a partially-deployed state. They may not
|
|
42
|
+
write Ruby day-to-day but they will run shell commands from a Makefile or a notebook.
|
|
43
|
+
|
|
44
|
+
### Application developers (secondary)
|
|
45
|
+
Developers building search features who want to inspect an index's mappings or analyzers, or
|
|
46
|
+
test an analyzer's tokenisation output against real text, without starting a Rails console or
|
|
47
|
+
writing a throwaway script. This use case is real but is equally well served by `pry` or
|
|
48
|
+
`bin/console` β the CLI advantage is marginal here.
|
|
49
|
+
|
|
50
|
+
### Who is *not* the audience
|
|
51
|
+
Non-technical users: the CLI requires credential management, understanding of OpenSearch
|
|
52
|
+
concepts, and comfort with a terminal. There is no case for making this accessible to users
|
|
53
|
+
who are not already technical. If non-technical access is a goal, it belongs in a web UI, not
|
|
54
|
+
a CLI.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Use Cases and Proposed Command Surface
|
|
59
|
+
|
|
60
|
+
The proposed tool is named `os-sugar` (or `opensearch-sugar` if the gem ships an executable).
|
|
61
|
+
All commands respect `OPENSEARCH_URL`, `OPENSEARCH_USER`, and `OPENSEARCH_PASSWORD` from the
|
|
62
|
+
environment, with `--url`, `--user`, and `--password` flags available as overrides.
|
|
63
|
+
|
|
64
|
+
### Index management
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
os-sugar index list
|
|
68
|
+
# Lists all index names in the cluster.
|
|
69
|
+
# Useful for scripting, pipeline checks, and quick inspection.
|
|
70
|
+
# The Dashboard does this well too, but the CLI version is scriptable.
|
|
71
|
+
|
|
72
|
+
os-sugar index create NAME [--no-knn]
|
|
73
|
+
# Creates an index. Exits non-zero if it already exists (use open-or-create to be idempotent).
|
|
74
|
+
|
|
75
|
+
os-sugar index open-or-create NAME
|
|
76
|
+
# Idempotent create. Useful in deploy scripts.
|
|
77
|
+
|
|
78
|
+
os-sugar index delete NAME [--force]
|
|
79
|
+
# Deletes an index. Requires --force to prevent accidents.
|
|
80
|
+
|
|
81
|
+
os-sugar index exists NAME
|
|
82
|
+
# Exits 0 if the index exists, 1 if not. Designed for shell conditionals.
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Opinion:** `list`, `exists`, and `open-or-create` are the highest-value commands here β they
|
|
86
|
+
slot directly into deployment scripts. `delete` with a `--force` guard is also valuable for
|
|
87
|
+
teardown automation. Creating and browsing indexes interactively is better done in the Dashboard.
|
|
88
|
+
|
|
89
|
+
### Alias management
|
|
90
|
+
|
|
91
|
+
Zero-downtime index re-indexing (blue/green) is one of the most common OpenSearch operational
|
|
92
|
+
tasks, and it is annoying to do via the REST API. A CLI makes the pattern scriptable.
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
os-sugar alias list INDEX
|
|
96
|
+
# Lists all aliases for a given index.
|
|
97
|
+
|
|
98
|
+
os-sugar alias create INDEX ALIAS_NAME
|
|
99
|
+
# Adds an alias to an index.
|
|
100
|
+
|
|
101
|
+
os-sugar alias swap ALIAS_NAME --from OLD_INDEX --to NEW_INDEX
|
|
102
|
+
# Atomically removes the alias from OLD_INDEX and adds it to NEW_INDEX.
|
|
103
|
+
# This is the core blue/green re-index operation. High value.
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Opinion:** `alias swap` is the single most compelling CLI command in this entire proposal. It
|
|
107
|
+
is a common, error-prone, multi-step operation that the REST API makes awkward and the Dashboard
|
|
108
|
+
does not support as a single atomic action. Building this alone would justify the CLI.
|
|
109
|
+
|
|
110
|
+
### ML model management
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
os-sugar models list
|
|
114
|
+
# Lists all deployed models with their names, versions, and IDs.
|
|
115
|
+
# Output is tabular by default; --format json for scripting.
|
|
116
|
+
|
|
117
|
+
os-sugar models register NAME VERSION [--format TORCH_SCRIPT]
|
|
118
|
+
# Registers and deploys a model. Idempotent if the model already exists.
|
|
119
|
+
# Polls until deployment is complete or fails. Prints status as it waits.
|
|
120
|
+
|
|
121
|
+
os-sugar models delete NAME_OR_ID
|
|
122
|
+
# Undeploys and deletes a model.
|
|
123
|
+
|
|
124
|
+
os-sugar models status NAME_OR_ID
|
|
125
|
+
# Reports deployment status of a model.
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Opinion:** This is the second most compelling use case. ML model registration is
|
|
129
|
+
configuration-heavy and stateful β it is exactly the kind of operation that benefits from a
|
|
130
|
+
CLI with clear progress feedback and idempotent semantics. Wrapping the polling loop and
|
|
131
|
+
lifecycle in a command-line tool is a genuine improvement over scripting it by hand.
|
|
132
|
+
|
|
133
|
+
### Document operations
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
os-sugar index index-jsonl INDEX FILE --id-field FIELD
|
|
137
|
+
# Bulk-indexes a JSONL file into an index using the Sugar API.
|
|
138
|
+
# Low ceremony; useful for one-off data loads.
|
|
139
|
+
|
|
140
|
+
os-sugar index count INDEX
|
|
141
|
+
# Prints the document count. Useful in scripts and post-load verification.
|
|
142
|
+
|
|
143
|
+
os-sugar index clear INDEX [--force]
|
|
144
|
+
# Deletes all documents. Requires --force.
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Opinion:** `index-jsonl` and `count` are solid. `clear` is occasionally useful in dev/staging
|
|
148
|
+
teardown scripts. These are low-cost to implement and fill a genuine gap β the Dashboard has no
|
|
149
|
+
bulk-load-from-file capability.
|
|
150
|
+
|
|
151
|
+
### Text analysis
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
os-sugar index analyze INDEX --analyzer ANALYZER TEXT
|
|
155
|
+
# Runs the analyzer against TEXT and prints the resulting tokens.
|
|
156
|
+
# Useful when tuning analyzers; instant feedback loop.
|
|
157
|
+
|
|
158
|
+
os-sugar index analyze-field INDEX --field FIELD TEXT
|
|
159
|
+
# Same, but derives the analyzer from the field's mapping.
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Opinion:** These are genuinely useful for analyzer development and debugging. Running
|
|
163
|
+
`analyze` from the command line is faster and more convenient than curl or the Dashboard's
|
|
164
|
+
Dev Tools console when you are iterating on an analyzer configuration.
|
|
165
|
+
|
|
166
|
+
### Ingest pipeline management
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
os-sugar pipelines list
|
|
170
|
+
# Lists ingest pipelines.
|
|
171
|
+
|
|
172
|
+
os-sugar pipelines create-embedding NAME --model MODEL --field-map src:target [...]
|
|
173
|
+
# Creates a text-embedding pipeline.
|
|
174
|
+
|
|
175
|
+
os-sugar pipelines delete NAME
|
|
176
|
+
# Deletes a pipeline.
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Opinion:** Pipeline creation is closely coupled to ML model management and has similar
|
|
180
|
+
operational semantics β it makes sense to include it for completeness. `list` and `delete`
|
|
181
|
+
are also useful for housekeeping.
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## What to Deliberately Exclude
|
|
186
|
+
|
|
187
|
+
**Search and querying.** There are already good tools for this (`curl`, the OpenSearch
|
|
188
|
+
Dashboard Dev Tools, and dedicated query clients). Adding `os-sugar search INDEX --query '{...}'`
|
|
189
|
+
provides no advantage over `curl` and would require a JSON DSL design that is outside the gem's
|
|
190
|
+
scope.
|
|
191
|
+
|
|
192
|
+
**Settings and mappings inspection.** `GET /my_index/_settings` and `GET /my_index/_mappings`
|
|
193
|
+
are one-liner `curl` commands. A CLI wrapper adds nothing. Developers who want this output in a
|
|
194
|
+
readable format are better served by the Dashboard's index management pages.
|
|
195
|
+
|
|
196
|
+
**Cluster monitoring.** Health, shard allocation, node stats β all of this is handled better
|
|
197
|
+
by Grafana dashboards, the OpenSearch Dashboard, or dedicated monitoring tools. A CLI equivalent
|
|
198
|
+
would be immediately outdated.
|
|
199
|
+
|
|
200
|
+
**Schema management (applying mappings/settings from files).** This is genuinely useful
|
|
201
|
+
(`os-sugar index apply-settings INDEX settings.json`) but overlaps heavily with infrastructure-as-
|
|
202
|
+
code tools (Terraform OpenSearch provider, ansible roles). It may be worth adding later if
|
|
203
|
+
there is demonstrated demand, but it is not a day-one priority.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## On a TUI (TTY Toolkit)
|
|
208
|
+
|
|
209
|
+
**Not recommended.**
|
|
210
|
+
|
|
211
|
+
A TUI built on the `tty` gem family would give the CLI interactive menus, spinners, progress
|
|
212
|
+
bars, and formatted table output. Some of this is appealing β the model registration polling
|
|
213
|
+
loop would benefit from a progress indicator, and `models list` output in a nice table is
|
|
214
|
+
genuinely nicer to read.
|
|
215
|
+
|
|
216
|
+
The problem is scope and maintenance. The `tty` ecosystem (tty-prompt, tty-table, tty-spinner,
|
|
217
|
+
tty-color, etc.) is a significant dependency footprint and requires active maintenance as the
|
|
218
|
+
gem evolves. TUI components also tend to interact badly with CI/CD environments, piped output,
|
|
219
|
+
and non-interactive terminals β exactly the use cases where this CLI is most valuable.
|
|
220
|
+
|
|
221
|
+
The practical alternative is simpler: use `tty-spinner` for the model registration polling loop
|
|
222
|
+
(one gem, one use case, well-isolated) and plain text output everywhere else. Tabular output
|
|
223
|
+
can be produced with `format` and `ljust` without any gem dependency. The Dashboard handles the
|
|
224
|
+
visual layer for interactive exploration.
|
|
225
|
+
|
|
226
|
+
Anyone who wants a REPL with rich interactivity can load the gem in `pry` or `irb` and has the
|
|
227
|
+
full Ruby object model available.
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Implementation Notes
|
|
232
|
+
|
|
233
|
+
### Framework: `dry-cli`
|
|
234
|
+
|
|
235
|
+
`dry-cli` is the right choice. It provides:
|
|
236
|
+
- Subcommand routing (`os-sugar index create`, `os-sugar models list`)
|
|
237
|
+
- Typed argument and option definitions with descriptions and defaults
|
|
238
|
+
- Auto-generated `--help` at every level
|
|
239
|
+
- Clean separation between command definitions and implementation
|
|
240
|
+
|
|
241
|
+
The commands themselves are thin wrappers over the Sugar API. Each command class initialises a
|
|
242
|
+
`Client`, calls the appropriate Sugar method, and formats output. Error handling is straightforward:
|
|
243
|
+
rescue `OpenSearch::Sugar::Error` and `OpenSearch::Transport::Transport::Error`, print a message to
|
|
244
|
+
stderr, exit non-zero.
|
|
245
|
+
|
|
246
|
+
### Distribution
|
|
247
|
+
|
|
248
|
+
The CLI lives in a separate gem, `opensearch-sugar-cli`, that depends on `opensearch-sugar`.
|
|
249
|
+
This keeps the core library free of CLI dependencies (`dry-cli`, `tty-spinner` if used) and
|
|
250
|
+
allows the CLI to be versioned and distributed independently. The `opensearch-sugar` gem stays
|
|
251
|
+
focused on its Ruby API.
|
|
252
|
+
|
|
253
|
+
### Environment and configuration
|
|
254
|
+
|
|
255
|
+
All connection parameters are read from `OPENSEARCH_URL`, `OPENSEARCH_USER`, and
|
|
256
|
+
`OPENSEARCH_PASSWORD`, consistent with the existing Sugar defaults. A `--config FILE`
|
|
257
|
+
option pointing to a YAML or `.env` file would be a useful addition for multi-cluster workflows.
|