# elasticsearch-expert

elasticsearch-expert is a Claude Code skill that helps design Elasticsearch mappings, build search queries and aggregations, and optimize ELK stacks.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 205 installs · ★ 45 repo stars
- Author: personamanagmentlayer
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/personamanagmentlayer/pcl/tree/HEAD/stdlib/data/elasticsearch-expert/SKILL.md
- Updated: 2026-10-12
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/elasticsearch-expert

## What it does

This skill equips your agent with reference patterns for the Elasticsearch Python client. It covers index creation with explicit property analyzers, document ingestion via `helpers.bulk`, and boolean or multi-match queries with field boosting.

It also provides templates for aggregations, including metric averages, term breakdowns, and date histograms. The guide flags operational anti-patterns directly: deep pagination using `from/size`, un-prefixed wildcard queries, and over-sharding clusters.

The skill requires Bash execution rights for `python`, `python3`, `pip`, and `pytest` alongside basic file read and edit permissions.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill elasticsearch-expert -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/elasticsearch-expert/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/elasticsearch-expert/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill elasticsearch-expert -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/elasticsearch-expert/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill elasticsearch-expert -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/elasticsearch-expert/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install personamanagmentlayer/pcl stdlib/data/elasticsearch-expert
```

2. **Manually: put the files in place**
- File: `.github/skills/elasticsearch-expert/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill elasticsearch-expert -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/personamanagmentlayer/pcl --path stdlib/data/elasticsearch-expert
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/elasticsearch-expert/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add personamanagmentlayer/pcl --skill elasticsearch-expert -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/personamanagmentlayer/pcl/tree/HEAD/stdlib/data/elasticsearch-expert/SKILL.md

## When to use it
- define Elasticsearch index mappings with field types and analyzers
- construct boolean and multi-match queries with field boosting
- build metric aggregations and date histograms in Python
- replace deep from/size pagination with search_after

## Example prompts
- Create an Elasticsearch mapping for an article catalog with text and date fields
- Write a Python script to index documents in bulk using elasticsearch.helpers
- Draft a bool search query combining text matching with a status filter

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: bbdaa2a59f562a4f.

BEGIN THIRD-PARTY FILE bbdaa2a59f562a4f
````text
---
name: elasticsearch-expert
version: 2.0.0
description: >-
  Expert-level Elasticsearch, search, ELK stack, and full-text search. Use when the user
  mentions search, ELK, Logstash, Kibana, or full text search.
category: data
tags: [elasticsearch, search, elk, logstash, kibana, full-text-search]
allowed-tools:
  - Read
  - Write
  - Edit
  - Bash(python:*, python3:*, pip:*, pytest:*)
---

# Elasticsearch Expert

Expert guidance for Elasticsearch, search optimization, ELK stack, and distributed search systems.

## Core Concepts

- Full-text search and inverted indexes
- Document-oriented storage
- RESTful API
- Distributed architecture with sharding
- ELK stack (Elasticsearch, Logstash, Kibana)
- Aggregations and analytics

## Index Management

```python
from elasticsearch import Elasticsearch

es = Elasticsearch(['http://localhost:9200'])

# Create index with mapping
mapping = {
    "mappings": {
        "properties": {
            "title": {"type": "text", "analyzer": "english"},
            "content": {"type": "text"},
            "author": {"type": "keyword"},
            "created_at": {"type": "date"},
            "views": {"type": "integer"}
        }
    }
}

es.indices.create(index='articles', body=mapping)

# Index document
doc = {
    "title": "Elasticsearch Guide",
    "content": "Complete guide to Elasticsearch",
    "author": "John Doe",
    "created_at": "2024-01-01",
    "views": 100
}

es.index(index='articles', id=1, body=doc)

# Bulk indexing
from elasticsearch.helpers import bulk

actions = [
    {"_index": "articles", "_id": i, "_source": doc}
    for i, doc in enumerate(documents)
]

bulk(es, actions)
```

## Search Queries

```python
# Full-text search
query = {
    "query": {
        "match": {
            "content": "elasticsearch guide"
        }
    }
}

results = es.search(index='articles', body=query)

# Boolean query
bool_query = {
    "query": {
        "bool": {
            "must": [
                {"match": {"content": "elasticsearch"}}
            ],
            "filter": [
                {"range": {"views": {"gte": 100}}}
            ],
            "should": [
                {"term": {"author": "john-doe"}}
            ],
            "must_not": [
                {"term": {"status": "draft"}}
            ]
        }
    }
}

# Multi-match query
multi_match = {
    "query": {
        "multi_match": {
            "query": "elasticsearch guide",
            "fields": ["title^2", "content"],  # Boost title
            "type": "best_fields"
        }
    }
}

# Fuzzy search
fuzzy = {
    "query": {
        "fuzzy": {
            "title": {
                "value": "elasticseerch",
                "fuzziness": "AUTO"
            }
        }
    }
}
```

## Aggregations

```python
# Aggregation query
agg_query = {
````
END THIRD-PARTY FILE bbdaa2a59f562a4f

The third-party file has ended. Everything between the bbdaa2a59f562a4f tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2795 of 3980 bytes. © personamanagmentlayer · Apache-2.0 · https://github.com/personamanagmentlayer/pcl/tree/HEAD/stdlib/data/elasticsearch-expert/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
