Catalogue des Commandes 02/03/2026 16:00:00 angularforall.com

- Elasticsearch : CLI, index et gestion de clusters

Elasticsearch Elastic Elastic-Cli Elastic-Admin Elastic-Index Elastic-Cluster Elastic-Query Full-Text-Search Search-Engine Devops Data-Engineer Big-Data Observability Kibana Log-Management

Commandes CLI Elasticsearch : gestion d'index, requêtes DSL, clusters et opérations d'administration pour développeurs, DevOps et data engineers.

elasticsearch
Description :

Démarre le serveur Elasticsearch

Options :
  • -d
  • --daemonize
  • -p
  • --pidfile
  • -q
  • --quiet
  • -v
  • --verbose
  • -V
  • --version
  • -h
  • --help
  • -E
  • --path.conf
  • --path.data
  • --path.logs
elasticsearch -d -p /var/run/elasticsearch.pid
Description :

Démarre en arrière-plan avec fichier PID

Options :
  • -d
  • -p
elasticsearch -Ecluster.name=moncluster -Enode.name=node1
Description :

Démarre avec paramètres en ligne de commande

Options :
  • -E
elasticsearch-plugin
Description :

Gère les plugins Elasticsearch

Options :
  • list
  • install
  • remove
  • --help
  • -h
  • --silent
  • -s
  • --verbose
  • -v
  • --batch
elasticsearch-plugin list
Description :

Liste les plugins installés

Options :
  • --help
elasticsearch-plugin install analysis-icu
Description :

Installe le plugin ICU

Options :
  • --batch
  • --silent
  • --verbose
elasticsearch-plugin install file:///path/to/plugin.zip
Description :

Installe un plugin depuis un fichier local

Options :
  • --batch
elasticsearch-plugin install https://example.com/plugin.zip
Description :

Installe un plugin depuis une URL

Options :
  • --batch
elasticsearch-plugin remove analysis-icu
Description :

Désinstalle un plugin

Options :
  • --silent
  • --verbose
elasticsearch-certutil
Description :

Gère les certificats pour Elasticsearch

Options :
  • ca
  • cert
  • csr
  • http
  • --help
  • -h
  • --silent
  • -s
elasticsearch-certutil ca
Description :

Génère une autorité de certification (CA)

Options :
  • --pem
  • --days
  • --keysize
  • --out
  • --pass
  • --silent
elasticsearch-certutil ca --pem --out ca.zip
Description :

Génère une CA au format PEM

Options :
  • --pem
  • --out
elasticsearch-certutil cert --ca ca.zip --dns localhost --ip 127.0.0.1 --out cert.zip
Description :

Génère un certificat signé par la CA

Options :
  • --ca
  • --dns
  • --ip
  • --name
  • --out
  • --pass
  • --multiple
  • --keysize
  • --days
elasticsearch-certutil http
Description :

Génère des certificats pour HTTP (REST API)

Options :
  • --dns
  • --ip
  • --out
  • --pass
  • --silent
elasticsearch-keystore
Description :

Gère le keystore sécurisé Elasticsearch

Options :
  • create
  • list
  • add
  • remove
  • show
  • passwd
  • has-passwd
  • --help
  • -h
  • --silent
  • -s
  • --verbose
  • -v
  • -f ⚠️
  • --force ⚠️
elasticsearch-keystore create
Description :

Crée un nouveau keystore

Options :
  • -p
  • --stdin
  • -f ⚠️
  • --force ⚠️
elasticsearch-keystore list
Description :

Liste les entrées du keystore

elasticsearch-keystore add s3.client.default.access_key
Description :

Ajoute une clé au keystore

Options :
  • --stdin
  • -x
  • --force ⚠️
elasticsearch-keystore remove s3.client.default.access_key
Description :

Supprime une clé du keystore

elasticsearch-keystore show s3.client.default.access_key
Description :

Affiche la valeur d'une clé

elasticsearch-node
Description :

Gère les nœuds Elasticsearch (maintenance)

Options :
  • repurpose
  • unsafe-bootstrap
  • detach-cluster
  • override-version
  • remove-settings
  • --help
  • -h
elasticsearch-node repurpose
Description :

Change le rôle d'un nœud

elasticsearch-node unsafe-bootstrap
Description :

Force le bootstrap d'un cluster (urgence)

elasticsearch-node detach-cluster
Description :

Détache un nœud du cluster

elasticsearch-shard
Description :

Gère les shards Elasticsearch

Options :
  • remove-corrupted-shard
  • --help
  • -h
elasticsearch-shard remove-corrupted-shard --index monindex --shard-id 0
Description :

Supprime un shard corrompu

Options :
  • --index
  • --shard-id
elasticsearch-saml-metadata
Description :

Génère les métadonnées SAML

Options :
  • --realm ⚠️
  • --out
  • --help
elasticsearch-saml-metadata --realm saml1 --out metadata.xml
Description :

Génère les métadonnées pour un realm SAML

Options :
  • --realm ⚠️
  • --out
elasticsearch-setup-passwords
Description :

Initialise les mots de passe des utilisateurs built-in

Options :
  • auto
  • interactive
  • --help
  • -h
  • --batch
elasticsearch-setup-passwords auto
Description :

Génère des mots de passe aléatoires

Options :
  • --batch
elasticsearch-setup-passwords interactive
Description :

Définit les mots de passe interactivement

elasticsearch-users
Description :

Gère les utilisateurs du file realm

Options :
  • useradd
  • userdel
  • passwd
  • roles
  • list
  • --help
  • -h
elasticsearch-users useradd monuser -p monmotdepasse -r superuser
Description :

Crée un utilisateur avec rôle

Options :
  • -p
  • --password
  • -r ⚠️
  • --role ⚠️
elasticsearch-users userdel monuser
Description :

Supprime un utilisateur

elasticsearch-users passwd monuser -p nouveau
Description :

Change le mot de passe d'un utilisateur

Options :
  • -p
  • --password
elasticsearch-users roles monuser -a kibana_admin -r monitoring_user
Description :

Ajoute/supprime des rôles (-a = add, -r = remove)

Options :
  • -a
  • --add
  • -r ⚠️
  • --remove ⚠️
elasticsearch-users list
Description :

Liste tous les utilisateurs

elasticsearch-syskeygen
Description :

Génère une clé système pour le chiffrement

Options :
  • --help
  • -h
curl -X GET "localhost:9200/"
Description :

Vérifie que Elasticsearch est en ligne

Options :
  • -u
  • --user
  • -k
  • --insecure
  • -H
  • --header
curl -X GET "localhost:9200/_cluster/health"
Description :

Affiche la santé du cluster

Options :
  • ?pretty
  • ?format=json
  • ?level=indices
  • ?level=shards
curl -X GET "localhost:9200/_cluster/health?pretty"
Description :

Santé du cluster formatée

curl -X GET "localhost:9200/_cluster/state"
Description :

État complet du cluster

Options :
  • ?pretty
  • ?filter_path=metadata.indices
curl -X GET "localhost:9200/_cluster/stats"
Description :

Statistiques du cluster

Options :
  • ?pretty
  • ?human
curl -X GET "localhost:9200/_cluster/settings"
Description :

Affiche les paramètres du cluster

Options :
  • ?pretty
  • ?flat_settings=true
  • ?include_defaults=true
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'{"transient": {"cluster.routing.allocation.enable": "none"}}'
Description :

Modifie les paramètres du cluster

curl -X GET "localhost:9200/_cluster/pending_tasks"
Description :

Tâches en attente dans le cluster

Options :
  • ?pretty
curl -X GET "localhost:9200/_nodes"
Description :

Informations sur tous les nœuds

Options :
  • ?pretty
  • ?filter_path=nodes.*.name
  • ?metric=os,process
curl -X GET "localhost:9200/_nodes/stats"
Description :

Statistiques des nœuds

Options :
  • ?pretty
  • ?metric=indices,jvm
  • ?human
curl -X GET "localhost:9200/_nodes/hot_threads"
Description :

Threads les plus actifs

Options :
  • ?threads=5
  • ?interval=2s
  • ?type=cpu
curl -X GET "localhost:9200/_cat/nodes?v"
Description :

Liste les nœuds (format cat)

Options :
  • ?v
  • &h=name,ip,heap.percent,ram.percent,load ⚠️
  • &s=name ⚠️
curl -X GET "localhost:9200/_cat/indices?v"
Description :

Liste tous les index

Options :
  • ?v
  • &s=index ⚠️
  • &h=index,health,status,pri,rep,docs.count,store.size ⚠️
curl -X GET "localhost:9200/_cat/shards?v"
Description :

Liste tous les shards

Options :
  • ?v
  • &h=index,shard,prirep,state,node ⚠️
curl -X GET "localhost:9200/_cat/segments?v"
Description :

Informations sur les segments Lucene

Options :
  • ?v
  • &h=index,shard,segment,size,size.memory ⚠️
curl -X GET "localhost:9200/_cat/recovery?v"
Description :

État de la récupération des shards

Options :
  • ?v
  • &active_only=true ⚠️
curl -X GET "localhost:9200/_cat/health?v"
Description :

Santé du cluster (format cat)

Options :
  • ?v
  • &ts=false ⚠️
curl -X GET "localhost:9200/_cat/allocation?v"
Description :

Allocation des shards par nœud

Options :
  • ?v
  • &h=node,shards,disk.percent,disk.used,disk.avail ⚠️
curl -X GET "localhost:9200/_cat/thread_pool?v"
Description :

État des pools de threads

Options :
  • ?v
  • &h=node,name,active,rejected,completed,queue ⚠️
curl -X GET "localhost:9200/_cat/tasks?v"
Description :

Tâches en cours d'exécution

Options :
  • ?v
  • &detailed ⚠️
curl -X GET "localhost:9200/_cat/templates?v"
Description :

Liste les templates d'index

Options :
  • ?v
  • &s=name ⚠️
curl -X GET "localhost:9200/_cat/plugins?v"
Description :

Liste les plugins installés

Options :
  • ?v
curl -X GET "localhost:9200/_cat/fielddata?v"
Description :

Utilisation de la mémoire fielddata

Options :
  • ?v
  • &fields=* ⚠️
curl -X GET "localhost:9200/_cat/count/monindex?v"
Description :

Nombre de documents dans un index

Options :
  • ?v
curl -X GET "localhost:9200/_cat/master?v"
Description :

Affiche le nœud master

Options :
  • ?v
curl -X GET "localhost:9200/_cat/nodeattrs?v"
Description :

Attributs personnalisés des nœuds

Options :
  • ?v
curl -X GET "localhost:9200/_cat/repositories?v"
Description :

Liste les repositories de snapshot

Options :
  • ?v
curl -X GET "localhost:9200/_cat/snapshots/mon_repo?v"
Description :

Liste les snapshots dans un repository

Options :
  • ?v
  • &s=id ⚠️
curl -X GET "localhost:9200/_cat/aliases?v"
Description :

Liste les alias d'index

Options :
  • ?v
  • &h=alias,index ⚠️
curl -X GET "localhost:9200/_cat/ml/anomaly_detectors?v"
Description :

Liste les jobs de détection d'anomalies

Options :
  • ?v
curl -X GET "localhost:9200/_cat/transforms?v"
Description :

Liste les transforms

Options :
  • ?v
curl -X PUT "localhost:9200/monindex"
Description :

Crée un index

Options :
  • -d
  • --data
curl -X PUT "localhost:9200/monindex" -H 'Content-Type: application/json' -d'{"settings": {"number_of_shards": 3, "number_of_replicas": 1}}'
Description :

Crée un index avec paramètres

curl -X PUT "localhost:9200/monindex" -H 'Content-Type: application/json' -d'{"mappings": {"properties": {"name": {"type": "text"}, "age": {"type": "integer"}}}}'
Description :

Crée un index avec mappings

curl -X DELETE "localhost:9200/monindex"
Description :

Supprime un index

curl -X DELETE "localhost:9200/index-*"
Description :

Supprime plusieurs index par pattern

curl -X GET "localhost:9200/monindex"
Description :

Récupère les informations d'un index

Options :
  • ?pretty
curl -X GET "localhost:9200/monindex/_mapping"
Description :

Affiche le mapping d'un index

Options :
  • ?pretty
curl -X GET "localhost:9200/monindex/_settings"
Description :

Affiche les paramètres d'un index

Options :
  • ?pretty
  • ?flat_settings=true
curl -X GET "localhost:9200/monindex/_stats"
Description :

Statistiques d'un index

Options :
  • ?pretty
curl -X GET "localhost:9200/monindex/_segments"
Description :

Segments d'un index

Options :
  • ?pretty
  • ?verbose
curl -X POST "localhost:9200/monindex/_close"
Description :

Ferme un index

curl -X POST "localhost:9200/monindex/_open"
Description :

Ouvre un index fermé

curl -X POST "localhost:9200/monindex/_freeze"
Description :

Gèle un index (réduit mémoire)

curl -X POST "localhost:9200/monindex/_unfreeze"
Description :

Dégèle un index

curl -X POST "localhost:9200/monindex/_forcemerge?max_num_segments=1"
Description :

Force la fusion des segments

Options :
  • ?max_num_segments
  • ?only_expunge_deletes
  • ?flush
curl -X POST "localhost:9200/monindex/_refresh"
Description :

Rafraîchit un index (rend les documents visibles)

curl -X POST "localhost:9200/monindex/_flush"
Description :

Flushe les transactions vers le disque

Options :
  • ?force
  • ?wait_if_ongoing
curl -X POST "localhost:9200/monindex/_clear_cache"
Description :

Vide les caches de l'index

Options :
  • ?fielddata=true
  • ?query=true
  • ?request=true
curl -X POST "localhost:9200/monindex/_rollover"
Description :

Crée un nouvel index quand l'actuel est plein

Options :
  • -d
  • --data
curl -X POST "localhost:9200/monindex/_rollover/monindex-000002" -H 'Content-Type: application/json' -d'{"conditions": {"max_age": "7d", "max_docs": 1000000}}'
Description :

Rollover avec conditions

curl -X POST "localhost:9200/monindex/_shrink/monindex-reduit" -H 'Content-Type: application/json' -d'{"settings": {"index.number_of_shards": 1}}'
Description :

Réduit le nombre de shards

curl -X POST "localhost:9200/monindex/_split/monindex-etendu" -H 'Content-Type: application/json' -d'{"settings": {"index.number_of_shards": 10}}'
Description :

Augmente le nombre de shards

curl -X POST "localhost:9200/monindex/_clone/monindex-clone"
Description :

Clone un index

curl -X PUT "localhost:9200/monindex/_alias/monalias"
Description :

Crée un alias pour un index

curl -X POST "localhost:9200/_aliases" -H 'Content-Type: application/json' -d'{"actions": [{"add": {"index": "monindex", "alias": "monalias"}}]}'
Description :

Gère les alias (actions multiples)

curl -X POST "localhost:9200/_aliases" -H 'Content-Type: application/json' -d'{"actions": [{"remove": {"index": "monindex", "alias": "monalias"}}]}'
Description :

Supprime un alias

curl -X POST "localhost:9200/_aliases" -H 'Content-Type: application/json' -d'{"actions": [{"add": {"index": "monindex", "alias": "monalias", "filter": {"term": {"status": "active"}}}}]}'
Description :

Alias avec filtre

curl -X GET "localhost:9200/_alias/monalias"
Description :

Affiche les index d'un alias

curl -X PUT "localhost:9200/_template/montemplate" -H 'Content-Type: application/json' -d'{"index_patterns": ["logs-*"], "settings": {"number_of_shards": 1}}'
Description :

Crée un template d'index

curl -X GET "localhost:9200/_template/montemplate"
Description :

Récupère un template

curl -X DELETE "localhost:9200/_template/montemplate"
Description :

Supprime un template

curl -X PUT "localhost:9200/_index_template/montemplate" -H 'Content-Type: application/json' -d'{"index_patterns": ["logs-*"], "template": {"settings": {"number_of_shards": 1}}}'
Description :

Crée un template d'index (nouvelle API composable)

curl -X GET "localhost:9200/_index_template"
Description :

Liste les templates composables

curl -X PUT "localhost:9200/_component_template/moncomponent" -H 'Content-Type: application/json' -d'{"template": {"mappings": {"properties": {"@timestamp": {"type": "date"}}}}}'
Description :

Crée un component template

curl -X POST "localhost:9200/monindex/_doc" -H 'Content-Type: application/json' -d'{"name": "John", "age": 30}'
Description :

Indexe un document (ID auto-généré)

Options :
  • ?pipeline
  • ?routing
  • ?refresh
curl -X PUT "localhost:9200/monindex/_doc/1" -H 'Content-Type: application/json' -d'{"name": "John", "age": 30}'
Description :

Indexe un document avec ID spécifique

Options :
  • ?op_type=create
  • ?version=2
  • ?version_type=external
curl -X POST "localhost:9200/_bulk" -H 'Content-Type: application/json' --data-binary @bulk.json
Description :

Indexe en masse (bulk API)

Options :
  • ?pipeline
  • ?routing
  • ?refresh
curl -X GET "localhost:9200/monindex/_doc/1"
Description :

Récupère un document par ID

Options :
  • ?pretty
  • ?_source=true
  • ?_source_includes=name,age
  • ?_source_excludes=*
curl -X GET "localhost:9200/monindex/_doc/1?_source=name,age"
Description :

Récupère uniquement certains champs

Options :
  • ?_source
  • ?_source_includes
  • ?_source_excludes
curl -X HEAD "localhost:9200/monindex/_doc/1"
Description :

Vérifie si un document existe

curl -X GET "localhost:9200/monindex/_mget" -H 'Content-Type: application/json' -d'{"ids": ["1", "2", "3"]}'
Description :

Récupère plusieurs documents (multi-get)

curl -X POST "localhost:9200/monindex/_update/1" -H 'Content-Type: application/json' -d'{"doc": {"age": 31}}'
Description :

Met à jour partiellement un document

Options :
  • ?retry_on_conflict
  • ?routing
  • ?refresh
curl -X POST "localhost:9200/monindex/_update/1" -H 'Content-Type: application/json' -d'{"script": {"source": "ctx._source.age += params.count", "params": {"count": 1}}}'
Description :

Met à jour avec un script

curl -X POST "localhost:9200/monindex/_update/1" -H 'Content-Type: application/json' -d'{"doc": {"age": 31}, "doc_as_upsert": true}'
Description :

Update ou insert (upsert)

curl -X POST "localhost:9200/monindex/_update_by_query" -H 'Content-Type: application/json' -d'{"script": {"source": "ctx._source.age++"}, "query": {"match": {"name": "John"}}}'
Description :

Met à jour par requête

Options :
  • ?conflicts=proceed
  • ?wait_for_completion=false
  • ?scroll_size=1000
curl -X DELETE "localhost:9200/monindex/_doc/1"
Description :

Supprime un document

Options :
  • ?routing
  • ?refresh
  • ?version
curl -X POST "localhost:9200/monindex/_delete_by_query" -H 'Content-Type: application/json' -d'{"query": {"match": {"name": "John"}}}'
Description :

Supprime par requête

Options :
  • ?conflicts=proceed
  • ?scroll_size=1000
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"match_all": {}}}'
Description :

Recherche tous les documents

Options :
  • ?pretty
  • ?size=10
  • ?from=0
  • ?timeout=30s
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"match": {"name": "John"}}}'
Description :

Recherche full-text (match)

curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"term": {"status": "active"}}}'
Description :

Recherche exacte (term)

curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"terms": {"tags": ["elasticsearch", "database"]}}}'
Description :

Recherche sur plusieurs valeurs (terms)

curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"range": {"age": {"gte": 18, "lte": 65}}}}'
Description :

Recherche par plage (range)

Options :
  • gt
  • gte
  • lt
  • lte
  • boost
  • format ⚠️
  • time_zone
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"bool": {"must": [{"match": {"name": "John"}}], "filter": [{"term": {"status": "active"}}]}}}'
Description :

Requête booléenne

Options :
  • must
  • must_not
  • should
  • filter
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"multi_match": {"query": "elasticsearch", "fields": ["title^3", "content"]}}}'
Description :

Recherche sur plusieurs champs

Options :
  • fields
  • type
  • tie_breaker
  • operator
  • minimum_should_match
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"query_string": {"query": "(name:John OR name:Jane) AND age:>18"}}}'
Description :

Requête avec syntaxe Lucene

Options :
  • query
  • default_field
  • allow_leading_wildcard
  • analyze_wildcard
  • lenient
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"prefix": {"name": "Jo"}}}'
Description :

Recherche par préfixe

Options :
  • prefix
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"wildcard": {"name": "J*"}}}'
Description :

Recherche avec wildcard

Options :
  • wildcard
  • boost
  • case_insensitive
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"fuzzy": {"name": {"value": "Jonh", "fuzziness": "AUTO"}}}}'
Description :

Recherche approximative (fuzzy)

Options :
  • fuzziness
  • max_expansions
  • prefix_length
  • transpositions
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"regexp": {"name": "J.*n"}}}'
Description :

Recherche par expression régulière

Options :
  • regexp
  • flags
  • max_determinized_states
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"exists": {"field": "email"}}}'
Description :

Documents ayant un champ

Options :
  • exists
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"geo_distance": {"distance": "10km", "location": {"lat": 48.8566, "lon": 2.3522}}}}'
Description :

Recherche géographique par distance

Options :
  • geo_distance
  • geo_bounding_box
  • geo_polygon
  • geo_shape
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"match_all": {}}, "sort": [{"age": "desc"}, {"name": "asc"}]}'
Description :

Tri des résultats

Options :
  • sort
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"match_all": {}}, "from": 10, "size": 10}'
Description :

Pagination (from/size)

Options :
  • from
  • size
curl -X POST "localhost:9200/monindex/_search?scroll=1m" -H 'Content-Type: application/json' -d'{"query": {"match_all": {}}, "size": 1000}'
Description :

Scroll API (pagination profonde)

Options :
  • ?scroll
curl -X POST "localhost:9200/_search/scroll" -H 'Content-Type: application/json' -d'{"scroll": "1m", "scroll_id": "..."}'
Description :

Continue un scroll

curl -X DELETE "localhost:9200/_search/scroll" -H 'Content-Type: application/json' -d'{"scroll_id": "..."}'
Description :

Supprime un scroll

curl -X POST "localhost:9200/monindex/_pit?keep_alive=1m"
Description :

Crée un Point In Time (PIT) pour pagination

Options :
  • ?keep_alive
curl -X DELETE "localhost:9200/_pit" -H 'Content-Type: application/json' -d'{"id": "..."}'
Description :

Supprime un PIT

curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"match": {"name": "John"}}, "highlight": {"fields": {"name": {}}}}'
Description :

Surlignage des résultats

Options :
  • highlight
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"size": 0, "aggs": {"avg_age": {"avg": {"field": "age"}}}}'
Description :

Agrégation moyenne

Options :
  • aggs
  • size
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"size": 0, "aggs": {"by_city": {"terms": {"field": "city.keyword"}}}}'
Description :

Agrégation par termes (group by)

Options :
  • terms
  • size
  • order
  • min_doc_count
  • include
  • exclude
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"size": 0, "aggs": {"age_histogram": {"histogram": {"field": "age", "interval": 10}}}}'
Description :

Agrégation histogramme

Options :
  • histogram
  • interval
  • min_doc_count
  • extended_bounds
  • order
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"size": 0, "aggs": {"age_stats": {"stats": {"field": "age"}}}}'
Description :

Agrégation statistiques (min, max, avg, sum, count)

Options :
  • stats
  • extended_stats
  • percentiles
  • percentile_ranks
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"size": 0, "aggs": {"by_city": {"terms": {"field": "city.keyword"}, "aggs": {"avg_age": {"avg": {"field": "age"}}}}}}'
Description :

Agrégation imbriquée

curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"size": 0, "aggs": {"top_users": {"top_hits": {"size": 10, "sort": [{"age": "desc"}]}}}}'
Description :

Agrégation top_hits

Options :
  • top_hits
  • size
  • sort
  • _source
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"match": {"content": "elasticsearch"}}, "suggest": {"text": "elasticserch", "simple_phrase": {"phrase": {"field": "content"}}}}'
Description :

Suggestion de correction orthographique

Options :
  • suggest ⚠️
  • term
  • phrase
  • completion
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"profile": true, "query": {"match": {"name": "John"}}}'
Description :

Profile une requête (debug performance)

Options :
  • profile
curl -X POST "localhost:9200/monindex/_search?request_cache=false" -H 'Content-Type: application/json' -d'{"query": {"match": {"name": "John"}}}'
Description :

Désactive le cache de requête

Options :
  • ?request_cache
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"match": {"name": "John"}}, "track_total_hits": true}'
Description :

Force le comptage exact des hits

Options :
  • track_total_hits
curl -X POST "localhost:9200/monindex/_count" -H 'Content-Type: application/json' -d'{"query": {"match": {"name": "John"}}}'
Description :

Compte les documents sans les retourner

curl -X POST "localhost:9200/monindex/_explain/1" -H 'Content-Type: application/json' -d'{"query": {"match": {"name": "John"}}}'
Description :

Explique pourquoi un document correspond

curl -X POST "localhost:9200/monindex/_validate/query?explain=true" -H 'Content-Type: application/json' -d'{"query": {"match": {"name": "John"}}}'
Description :

Valide une requête sans l'exécuter

Options :
  • ?explain
  • ?rewrite
curl -X POST "localhost:9200/_reindex" -H 'Content-Type: application/json' -d'{"source": {"index": "oldindex"}, "dest": {"index": "newindex"}}'
Description :

Réindexe les documents d'un index à un autre

Options :
  • ?wait_for_completion=false
  • ?requests_per_second=500
curl -X POST "localhost:9200/_reindex" -H 'Content-Type: application/json' -d'{"source": {"index": "oldindex", "query": {"match": {"status": "active"}}}, "dest": {"index": "newindex"}}'
Description :

Réindexe avec filtre

curl -X POST "localhost:9200/_reindex" -H 'Content-Type: application/json' -d'{"source": {"remote": {"host": "http://remote:9200"}, "index": "sourceindex"}, "dest": {"index": "localindex"}}'
Description :

Réindexe depuis un cluster distant

Options :
  • remote
curl -X GET "localhost:9200/_tasks?actions=*reindex&detailed"
Description :

Surveille les tâches de réindexation

Options :
  • ?actions
  • &detailed ⚠️
  • &group_by ⚠️
curl -X POST "localhost:9200/_tasks/task_id/_cancel"
Description :

Annule une tâche en cours

curl -X PUT "localhost:9200/_snapshot/mon_repo" -H 'Content-Type: application/json' -d'{"type": "fs", "settings": {"location": "/backup/elasticsearch"}}'
Description :

Crée un repository de snapshots

Options :
  • type
  • settings
curl -X GET "localhost:9200/_snapshot/mon_repo"
Description :

Vérifie un repository

curl -X PUT "localhost:9200/_snapshot/mon_repo/snapshot1?wait_for_completion=true" -H 'Content-Type: application/json' -d'{"indices": "monindex", "ignore_unavailable": true}'
Description :

Crée un snapshot

Options :
  • ?wait_for_completion
  • ?master_timeout
curl -X GET "localhost:9200/_snapshot/mon_repo/snapshot1"
Description :

Informations sur un snapshot

Options :
  • ?verbose
curl -X GET "localhost:9200/_snapshot/mon_repo/snapshot1/_status"
Description :

Statut d'un snapshot en cours

curl -X POST "localhost:9200/_snapshot/mon_repo/snapshot1/_restore" -H 'Content-Type: application/json' -d'{"indices": "monindex"}'
Description :

Restaure un snapshot

Options :
  • ?wait_for_completion
curl -X POST "localhost:9200/_snapshot/mon_repo/snapshot1/_restore" -H 'Content-Type: application/json' -d'{"indices": "monindex", "rename_pattern": "monindex", "rename_replacement": "restored_monindex"}'
Description :

Restaure avec renommage

curl -X DELETE "localhost:9200/_snapshot/mon_repo/snapshot1"
Description :

Supprime un snapshot

curl -X POST "localhost:9200/_slm/policy/nightly-backup" -H 'Content-Type: application/json' -d'{"schedule": "0 30 1 * * ?", "name": "<nightly-{now/d}>", "repository": "mon_repo", "config": {"indices": ["*"]}}'
Description :

Crée une politique de snapshot automatique (SLM)

curl -X POST "localhost:9200/_slm/policy/nightly-backup/_execute"
Description :

Exécute immédiatement une politique SLM

curl -X GET "localhost:9200/_slm/policy"
Description :

Liste les politiques SLM

curl -X GET "localhost:9200/_ilm/policy"
Description :

Liste les politiques ILM (Index Lifecycle Management)

curl -X PUT "localhost:9200/_ilm/policy/logs-policy" -H 'Content-Type: application/json' -d'{"phases": {"hot": {"min_age": "0ms", "actions": {"rollover": {"max_size": "50gb"}}}, "delete": {"min_age": "30d", "actions": {"delete": {}}}}}'
Description :

Crée une politique ILM

curl -X POST "localhost:9200/monindex/_ilm/retry"
Description :

Relance une action ILM en échec

curl -X GET "localhost:9200/monindex/_ilm/explain"
Description :

Explique l'état ILM d'un index

curl -X POST "localhost:9200/_security/user/monuser" -H 'Content-Type: application/json' -d'{"password": "monmotdepasse", "roles": ["kibana_user"]}'
Description :

Crée un utilisateur via API

curl -X GET "localhost:9200/_security/user"
Description :

Liste les utilisateurs

curl -X DELETE "localhost:9200/_security/user/monuser"
Description :

Supprime un utilisateur

curl -X POST "localhost:9200/_security/role/monrole" -H 'Content-Type: application/json' -d'{"cluster": ["all"], "indices": [{"names": ["*"], "privileges": ["read"]}]}'
Description :

Crée un rôle

curl -X GET "localhost:9200/_security/role"
Description :

Liste les rôles

curl -X POST "localhost:9200/_security/api_key" -H 'Content-Type: application/json' -d'{"name": "mon_api_key", "role_descriptors": {}}'
Description :

Crée une clé API

Options :
  • ?refresh
curl -X GET "localhost:9200/_security/api_key"
Description :

Récupère les clés API

Options :
  • ?owner=true
curl -X DELETE "localhost:9200/_security/api_key" -H 'Content-Type: application/json' -d'{"name": "mon_api_key"}'
Description :

Révoque une clé API

curl -X POST "localhost:9200/_security/service/elastic/kibana/credential/token/kibana_token"
Description :

Crée un token de service

curl -X GET "localhost:9200/_license"
Description :

Affiche la licence

Options :
  • ?local
curl -X POST "localhost:9200/_license/start_trial?acknowledge=true"
Description :

Démarre l'essai de 30 jours

Options :
  • ?acknowledge
curl -X GET "localhost:9200/_xpack"
Description :

Informations sur les fonctionnalités X-Pack

Options :
  • ?categories
  • &human ⚠️
curl -X GET "localhost:9200/_xpack/usage"
Description :

Statistiques d'utilisation X-Pack

curl -X POST "localhost:9200/_flush/synced"
Description :

Flush synchronisé sur tous les index

curl -X POST "localhost:9200/_all/_flush/synced"
Description :

Flush synchronisé sur tous les index (explicite)

curl -X POST "localhost:9200/_synced_flush"
Description :

Alias de flush synchronisé

curl -X POST "localhost:9200/_cache/clear"
Description :

Vide tous les caches

Options :
  • ?fielddata
  • &query ⚠️
  • &request ⚠️
curl -X POST "localhost:9200/_scripts/painless/_execute" -H 'Content-Type: application/json' -d'{"script": {"source": "params.a + params.b", "params": {"a": 1, "b": 2}}}'
Description :

Teste un script Painless

curl -X PUT "localhost:9200/_scripts/mon_script" -H 'Content-Type: application/json' -d'{"script": {"lang": "painless", "source": "ctx._source.age++"}}'
Description :

Stocke un script

curl -X GET "localhost:9200/_scripts/mon_script"
Description :

Récupère un script stocké

curl -X DELETE "localhost:9200/_scripts/mon_script"
Description :

Supprime un script stocké

curl -X POST "localhost:9200/_ingest/pipeline/mon_pipeline" -H 'Content-Type: application/json' -d'{"description": "Mon pipeline", "processors": [{"set": {"field": "processed", "value": true}}]}'
Description :

Crée un pipeline d'ingestion

curl -X GET "localhost:9200/_ingest/pipeline"
Description :

Liste les pipelines

curl -X POST "localhost:9200/_ingest/pipeline/_simulate" -H 'Content-Type: application/json' -d'{"pipeline": {"processors": [{"set": {"field": "processed", "value": true}}]}, "docs": [{"_source": {"name": "test"}}]}'
Description :

Simule un pipeline

curl -X DELETE "localhost:9200/_ingest/pipeline/mon_pipeline"
Description :

Supprime un pipeline

curl -X PUT "localhost:9200/_enrich/policy/mon_policy" -H 'Content-Type: application/json' -d'{"match": {"indices": "users", "match_field": "email", "enrich_fields": ["name", "age"]}}'
Description :

Crée une politique d'enrichissement

curl -X POST "localhost:9200/_enrich/policy/mon_policy/_execute"
Description :

Exécute une politique d'enrichissement

curl -X GET "localhost:9200/_enrich/policy"
Description :

Liste les politiques d'enrichissement

curl -X GET "localhost:9200/_data_stream"
Description :

Liste les data streams

curl -X PUT "localhost:9200/_data_stream/mon_data_stream"
Description :

Crée un data stream

curl -X DELETE "localhost:9200/_data_stream/mon_data_stream"
Description :

Supprime un data stream

curl -X GET "localhost:9200/_data_stream/_stats"
Description :

Statistiques des data streams

curl -X GET "localhost:9200/_transform"
Description :

Liste les transforms

curl -X PUT "localhost:9200/_transform/mon_transform" -H 'Content-Type: application/json' -d'{"source": {"index": ["source"]}, "dest": {"index": "dest"}, "pivot": {"group_by": {"user": {"terms": {"field": "user_id"}}}, "aggregations": {"total": {"sum": {"field": "amount"}}}}}'
Description :

Crée un transform

curl -X POST "localhost:9200/_transform/mon_transform/_start"
Description :

Démarre un transform

curl -X POST "localhost:9200/_transform/mon_transform/_stop"
Description :

Arrête un transform

Options :
  • ?force
curl -X GET "localhost:9200/_transform/mon_transform/_stats"
Description :

Statistiques d'un transform

curl -X DELETE "localhost:9200/_transform/mon_transform"
Description :

Supprime un transform

Options :
  • ?force
curl -X GET "localhost:9200/_ml/info"
Description :

Informations sur le Machine Learning

curl -X PUT "localhost:9200/_ml/anomaly_detectors/mon_job" -H 'Content-Type: application/json' -d'{"analysis_config": {"bucket_span": "15m", "detectors": [{"function": "mean", "field_name": "cpu"}]}, "data_description": {"time_field": "@timestamp"}}'
Description :

Crée un job de détection d'anomalies

curl -X POST "localhost:9200/_ml/anomaly_detectors/mon_job/_open"
Description :

Ouvre un job ML

curl -X POST "localhost:9200/_ml/anomaly_detectors/mon_job/_close"
Description :

Ferme un job ML

curl -X POST "localhost:9200/_ml/anomaly_detectors/mon_job/_start"
Description :

Démarre un job ML

curl -X POST "localhost:9200/_ml/anomaly_detectors/mon_job/_stop"
Description :

Arrête un job ML

curl -X GET "localhost:9200/_ml/anomaly_detectors/mon_job/_stats"
Description :

Statistiques d'un job ML

curl -X GET "localhost:9200/_ml/datafeeds"
Description :

Liste les datafeeds ML

curl -X GET "localhost:9200/_ml/filters"
Description :

Liste les filtres ML

curl -X GET "localhost:9200/_ml/calendars"
Description :

Liste les calendriers ML

curl -X GET "localhost:9200/_watcher/watch"
Description :

Liste les watches (alertes)

curl -X PUT "localhost:9200/_watcher/watch/mon_watch" -H 'Content-Type: application/json' -d'{"trigger": {"schedule": {"interval": "10m"}}, "input": {"search": {"request": {"indices": ["logs-*"], "body": {"query": {"match": {"level": "error"}}}}}}, "condition": {"compare": {"ctx.payload.hits.total": {"gt": 0}}}, "actions": {"log": {"logging": {"text": "Erreurs détectées"}}}}'
Description :

Crée une watch

curl -X POST "localhost:9200/_watcher/watch/mon_watch/_execute"
Description :

Exécute manuellement une watch

curl -X DELETE "localhost:9200/_watcher/watch/mon_watch"
Description :

Supprime une watch

curl -X GET "localhost:9200/_watcher/stats"
Description :

Statistiques Watcher

curl -X POST "localhost:9200/_watcher/_start"
Description :

Démarre Watcher

curl -X POST "localhost:9200/_watcher/_stop"
Description :

Arrête Watcher

curl -X GET "localhost:9200/_graph/explore" -H 'Content-Type: application/json' -d'{"index": "logs", "query": {"match": {"message": "error"}}}'
Description :

Explore les relations (Graph)

curl -X POST "localhost:9200/_sql?format=txt" -H 'Content-Type: application/json' -d'{"query": "SELECT * FROM monindex WHERE age > 18"}'
Description :

Requête SQL

Options :
  • ?format=txt
  • ?format=json
  • ?format=csv
  • ?format=tsv
curl -X POST "localhost:9200/_sql/translate" -H 'Content-Type: application/json' -d'{"query": "SELECT * FROM monindex WHERE age > 18"}'
Description :

Traduit SQL en requête Elasticsearch

curl -X GET "localhost:9200/_sql/stats"
Description :

Statistiques SQL

curl -X POST "localhost:9200/_eql/search" -H 'Content-Type: application/json' -d'{"index": "logs", "query": "sequence by host [process where name=\"cmd.exe\"] [network where destination_port=443]"}'
Description :

Requête EQL (Event Query Language)

curl -X GET "localhost:9200/_eql/stats"
Description :

Statistiques EQL

curl -X POST "localhost:9200/_rollup/job/mon_rollup" -H 'Content-Type: application/json' -d'{"index_pattern": "logs-*", "rollup_index": "logs_rollup", "cron": "0 0 * * * ?", "page_size": 1000, "groups": {"date_histogram": {"field": "@timestamp", "interval": "1h"}}}'
Description :

Crée un job de rollup

curl -X POST "localhost:9200/_rollup/job/mon_rollup/_start"
Description :

Démarre un job de rollup

curl -X GET "localhost:9200/_rollup/job/mon_rollup"
Description :

Informations sur un job de rollup

curl -X GET "localhost:9200/_rollup/data/mon_rollup"
Description :

Récupère les données rollup

curl -X GET "localhost:9200/_searchable_snapshots/stats"
Description :

Statistiques des snapshots consultables

Options :
  • ?pretty
curl -X POST "localhost:9200/_migration/deprecations"
Description :

Vérifie les API dépréciées utilisées

Options :
  • ?index
curl -X POST "localhost:9200/_migration/upgrade/monindex"
Description :

Met à niveau un index vers la version actuelle

curl -X POST "localhost:9200/_migration/post_feature_upgrade"
Description :

Met à niveau les features après upgrade

curl -X GET "localhost:9200/_analyze" -H 'Content-Type: application/json' -d'{"analyzer": "standard", "text": "Ceci est un test"}'
Description :

Analyse un texte avec un analyseur

curl -X GET "localhost:9200/_analyze" -H 'Content-Type: application/json' -d'{"field": "name", "text": "John Doe"}'
Description :

Analyse avec l'analyseur d'un champ

curl -X POST "localhost:9200/monindex/_termvectors/1?fields=description"
Description :

Récupère les vecteurs de termes d'un document

Options :
  • ?fields
  • &term_statistics ⚠️
  • &field_statistics ⚠️
curl -X POST "localhost:9200/_mtermvectors" -H 'Content-Type: application/json' -d'{"docs": [{"_index": "monindex", "_id": "1", "fields": ["description"]}]}'
Description :

Multi termvectors

curl -X GET "localhost:9200/_field_caps?fields=name,age"
Description :

Capacités des champs à travers les index

Options :
  • ?fields
curl -X GET "localhost:9200/_nodes/reload_secure_settings"
Description :

Recharge les paramètres sécurisés (keystore)

curl -X GET "localhost:9200/_ssl/certificates"
Description :

Informations sur les certificats SSL

Options :
  • ?pretty
curl -X GET "localhost:9200/_autoscaling/policy"
Description :

Liste les politiques d'autoscaling

curl -X GET "localhost:9200/_autoscaling/capacity"
Description :

Capacité actuelle d'autoscaling

curl -X GET "localhost:9200/_logs/index.mappings"
Description :

Affiche le mapping des logs Elasticsearch

Partager