Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

elasticsearch-search

БесплатноБез исполняемых скриптовНе проверен

Configure and use Elasticsearch for full-text search, custom analyzers, aggregations, and index management. Use when a user needs to design search mappings…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Elasticsearch Search

Overview

Design and implement Elasticsearch search solutions including index mappings, custom analyzers, full-text queries, aggregations, and relevance tuning. Covers index lifecycle, search templates, and performance optimization.

Instructions

Connect first

Elasticsearch 8 and 9 start with security on: HTTPS, a generated elastic password and a CA certificate. Set the base URL once and add credentials from the environment (never in the command text). For a throwaway local node started with xpack.security.enabled=false, plain http://127.0.0.1:9200 works.

export ES_URL="https://127.0.0.1:9200"
# secured cluster: add to each curl  -u "elastic:$ELASTIC_PASSWORD" --cacert "$ES_CA_CERT"
# or with an API key:               -H "Authorization: ApiKey $ES_API_KEY"
curl -s "$ES_URL" -u "elastic:$ELASTIC_PASSWORD" --cacert "$ES_CA_CERT"

The commands below omit the credential flags to stay readable; add them on a secured cluster. A single shard is right for small indices (under tens of GB); more shards add overhead.

Task A: Create Index with Custom Mappings

# Create an index with explicit mappings and custom analyzers
curl -X PUT "$ES_URL/products" \
  -H "Content-Type: application/json" \
  -d '{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 1,
    "analysis": {
      "analyzer": {
        "product_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": ["lowercase", "asciifolding", "product_synonyms", "product_stemmer"]
        },
        "autocomplete_analyzer": {
          "type": "custom",
          "tokenizer": "autocomplete_tokenizer",
          "filter": ["lowercase"]
        }
      },
      "tokenizer": {
        "autocomplete_tokenizer": {
          "type": "edge_ngram",
          "min_gram": 2,
          "max_gram": 15,
          "token_chars": ["letter", "digit"]
        }
      },
      "filter": {
        "product_synonyms": {
          "type": "synonym",
          "synonyms": ["laptop,notebook", "phone,mobile,cellphone", "tv,television"]
        },
        "product_stemmer": {
          "type": "stemmer",
          "language": "english"
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "name": {
        "type": "text",
        "analyzer": "product_analyzer",
        "fields": {
          "autocomplete": { "type": "text", "analyzer": "autocomplete_analyzer", "search_analyzer": "standard" },
          "keyword": { "type": "keyword" }
        }
      },
      "description": { "type": "text", "analyzer": "product_analyzer" },
      "category": { "type": "keyword" },
      "price": { "type": "float" },
      "rating": { "type": "float" },
      "tags": { "type": "keyword" },
      "created_at": { "type": "date" },
      "in_stock": { "type": "boolean" }
    }
  }
}'

Task B: Full-Text Search Queries

curl -X POST "$ES_URL/products/_search" \
  -H "Content-Type: application/json" \
  -d '{
  "query": {
    "bool": {
      "must": {
        "multi_match": {
          "query": "wireless noise cancelling headphones",
          "fields": ["name^3", "description", "tags^2"],
          "type": "best_fields",
          "fuzziness": "AUTO"
        }
      },
      "filter": [
        { "term": { "in_stock": true } },
        { "range": { "price": { "gte": 50, "lte": 300 } } }
      ],
      "should": [{ "range": { "rating": { "gte": 4.0, "boost": 2.0 } } }]
    }
  },
  "highlight": {
    "fields": {
      "name": {},
      "description": { "fragment_size": 150 }
    }
  },
  "size": 20
}'
curl -X POST "$ES_URL/products/_search" \
  -H "Content-Type: application/json" \
  -d '{
  "query": {
    "bool": {
      "must": {
        "match": {
          "name.autocomplete": { "query": "wire", "operator": "and" }
        }
      },
      "filter": { "term": { "in_stock": true } }
    }
  },
  "size": 10
}'

Task C: Aggregations

curl -X POST "$ES_URL/products/_search" \
  -H "Content-Type: application/json" \
  -d '{
  "size": 0,
  "query": { "match": { "description": "wireless headphones" } },
  "aggs": {
    "categories": {
      "terms": { "field": "category", "size": 20 },
      "aggs": {
        "avg_price": { "avg": { "field": "price" } },
        "avg_rating": { "avg": { "field": "rating" } }
      }
    },
    "price_ranges": {
      "range": {
        "field": "price",
        "ranges": [
          { "key": "budget", "to": 50 },
          { "key": "mid-range", "from": 50, "to": 150 },
          { "key": "premium", "from": 150, "to": 300 },
          { "key": "luxury", "from": 300 }
        ]
      }
    }
  }
}'
# Date histogram aggregation for time-series analysis
curl -X POST "$ES_URL/logs-*/_search" \
  -H "Content-Type: application/json" \
  -d '{
  "size": 0,
  "query": { "range": { "@timestamp": { "gte": "now-7d" } } },
  "aggs": {
    "errors_over_time": {
      "date_histogram": {
        "field":
Полный SKILL.md на GitHub

Установить elasticsearch-search в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл elasticsearch-search?

Configure and use Elasticsearch for full-text search, custom analyzers, aggregations, and index management. Use when a user needs to design search mappings, write complex queries, build aggregation pipelines, tune relevance scoring, or optimize index performance for search workloads.

Как установить скилл elasticsearch-search?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл elasticsearch-search запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить elasticsearch-search с