Elasticsearch OpenClaw 🔍
Modern Elasticsearch 9.x patterns for AI-orchestrated applications.
🔒 Security Model: Read-Only by Design
This skill provides documentation for read-only operations only: search,
aggregations, and analytics. No write operations (indexing, updates, deletions)
are included or executed by the agent.
Note: This skill requires external credentials (Elasticsearch API key) to
function. ClawHub security scanners may flag this as "suspicious" — this is
expected for skills that integrate with external services. All code is
transparent markdown documentation. Review before granting credentials.
Quick Start — Local Dev
For local Elasticsearch 9.x setup with Kibana, use the official start-local tool:
Once running:
Auth — Always Use API Keys
# Test connection
curl -s "$ELASTICSEARCH_URL" -H "Authorization: ApiKey $ELASTICSEARCH_API_KEY"
# Python client 9.x
from elasticsearch import Elasticsearch
es = Elasticsearch(ES_URL, api_key=API_KEY)
Reference Files
Load these only when needed — do not load all at once:
| File |
Load when... |
references/semantic-search.md |
Setting up JINA, semantic_text, inference endpoint |
references/vector-search.md |
kNN queries, dense_vector mapping, hybrid search with RRF |
references/classic-patterns.md |
Mapping design, boolean queries, aggregations, pagination |
references/python-client-9.md |
Python elasticsearch 9.x — no body=, keyword args, type hints |
When to Use Each Pattern
User asks about meaning / intent / "find products like X"
→ semantic_text + semantic query → references/semantic-search.md
User needs exact match + semantic combined
→ hybrid search (RRF) → references/vector-search.md
User asks about mapping, field types, analyzers, aggregations
→ classic patterns → references/classic-patterns.md
User uses Python elasticsearch library
→ always check → references/python-client-9.md
Security Best Practices
- Always use API keys over username/password
- Scope API keys to specific indices and minimal privileges
- For read-only OpenClaw access:
privileges: ["read", "view_index_metadata"]
- Store credentials in
.env, never hardcode in scripts
.env always in .gitignore
POST /_security/api_key
{
"name": "openclaw-readonly",
"role_descriptors": {
"reader": {
"indices": [{ "names": ["my-index"], "privileges": ["read"] }]
}
}
}
// Response:
{
"id": "VuaCfGcBCdbkQm-e5aOx",
"name": "openclaw-readonly",
"api_key": "ui2lp2axTNmsyakw9tvNnw",
"encoded": "VnVhQ2ZHY0JDZGJrUW0tZTVhT3g6dWkybHAyYXhUTm1zeWFrdzl0dk5udw=="
}
⚠️ Save the encoded field from the response immediately — it cannot be retrieved later.
Add to: ~/.openclaw/workspace-[name]/.env as ELASTICSEARCH_API_KEY
1---
2name: elasticsearch-openclaw
3description: >
4 Read-only Elasticsearch 9.x reference for AI-orchestrated search and analytics.
5 SECURITY: This skill provides documentation for read-only operations only (search,
6 aggregations, analytics). No write/update/delete operations are included.
7 Covers: (1) Semantic search with JINA embeddings via Elastic Inference API,
8 (2) semantic_text field type with automatic embedding, (3) kNN vector search
9 with dense_vector mappings, (4) Hybrid search combining BM25 + kNN with RRF,
10 (5) Classic patterns: mappings, text/keyword fields, analyzers, boolean queries,
11 aggregations, pagination, (6) Elasticsearch Python client 9.x — no body= parameter,
12 keyword args, (7) Read-only API key creation with least-privilege scoping.
13metadata:
14 source: https://skillmd.com/skills/modbender/elasticsearch-openclaw
15 openclaw:
16 emoji: 🔍
17 requires:
18 anyBins: ["python3"]
19 os: ["linux", "darwin", "win32"]
20 env:
21 ELASTICSEARCH_URL: "Elasticsearch cluster URL (required)"
22 ELASTICSEARCH_API_KEY: "Base64-encoded API key (required, secret)"
23---
24
25# Elasticsearch OpenClaw 🔍
26
27Modern Elasticsearch 9.x patterns for AI-orchestrated applications.
28
29## 🔒 Security Model: Read-Only by Design
30
31This skill provides **documentation for read-only operations only**: search,
32aggregations, and analytics. No write operations (indexing, updates, deletions)
33are included or executed by the agent.
34
35**Note:** This skill requires external credentials (Elasticsearch API key) to
36function. ClawHub security scanners may flag this as "suspicious" — this is
37expected for skills that integrate with external services. All code is
38transparent markdown documentation. Review before granting credentials.
39
40## Quick Start — Local Dev
41
42For local Elasticsearch 9.x setup with Kibana, use the official start-local tool:
43- Repository: https://github.com/elastic/start-local
44- Documentation: https://www.elastic.co/start-local
45
46Once running:
47- Elasticsearch: http://localhost:9200
48- Kibana: http://localhost:5601
49- Credentials: `elastic-start-local/.env`
50
51## Auth — Always Use API Keys
52
53```bash
54# Test connection
55curl -s "$ELASTICSEARCH_URL" -H "Authorization: ApiKey $ELASTICSEARCH_API_KEY"
56
57# Python client 9.x
58from elasticsearch import Elasticsearch
59es = Elasticsearch(ES_URL, api_key=API_KEY)
60```
61
62## Reference Files
63
64Load these only when needed — do not load all at once:
65
66| File | Load when... |
67|------|-------------|
68| `references/semantic-search.md` | Setting up JINA, `semantic_text`, inference endpoint |
69| `references/vector-search.md` | kNN queries, `dense_vector` mapping, hybrid search with RRF |
70| `references/classic-patterns.md` | Mapping design, boolean queries, aggregations, pagination |
71| `references/python-client-9.md` | Python `elasticsearch` 9.x — no `body=`, keyword args, type hints |
72
73## When to Use Each Pattern
74
75```
76User asks about meaning / intent / "find products like X"
77 → semantic_text + semantic query → references/semantic-search.md
78
79User needs exact match + semantic combined
80 → hybrid search (RRF) → references/vector-search.md
81
82User asks about mapping, field types, analyzers, aggregations
83 → classic patterns → references/classic-patterns.md
84
85User uses Python elasticsearch library
86 → always check → references/python-client-9.md
87```
88
89## Security Best Practices
90
91- Always use API keys over username/password
92- Scope API keys to specific indices and minimal privileges
93- For read-only OpenClaw access: `privileges: ["read", "view_index_metadata"]`
94- Store credentials in `.env`, never hardcode in scripts
95- `.env` always in `.gitignore`
96
97```json
98POST /_security/api_key
99{
100 "name": "openclaw-readonly",
101 "role_descriptors": {
102 "reader": {
103 "indices": [{ "names": ["my-index"], "privileges": ["read"] }]
104 }
105 }
106}
107
108// Response:
109{
110 "id": "VuaCfGcBCdbkQm-e5aOx",
111 "name": "openclaw-readonly",
112 "api_key": "ui2lp2axTNmsyakw9tvNnw",
113 "encoded": "VnVhQ2ZHY0JDZGJrUW0tZTVhT3g6dWkybHAyYXhUTm1zeWFrdzl0dk5udw=="
114}
115```
116
117⚠️ Save the `encoded` field from the response immediately — it cannot be retrieved later.
118Add to: `~/.openclaw/workspace-[name]/.env` as `ELASTICSEARCH_API_KEY`