Elasticsearch – Commandes CLI, gestion d’index et administration de clusters

🏷️ Commandes & CLI 📅 09/03/2026 09:00:00 👤 Mezgani said
Elasticsearch Elastic Elastic Cli Elastic Commands 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, clusters et opérations d’administration. Guide pratique pour développeurs, DevOps et data engineers travaillant sur la recherche et l’analyse de données.

Ligne de commande :
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

Ligne de commande :
elasticsearch -d -p /var/run/elasticsearch.pid
Description :

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

Options :
  • -d
  • -p

Ligne de commande :
elasticsearch -Ecluster.name=moncluster -Enode.name=node1
Description :

Démarre avec paramètres en ligne de commande

Options :
  • -E

Ligne de commande :
elasticsearch-plugin
Description :

Gère les plugins Elasticsearch

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

Ligne de commande :
elasticsearch-plugin list
Description :

Liste les plugins installés

Options :
  • --help

Ligne de commande :
elasticsearch-plugin install analysis-icu
Description :

Installe le plugin ICU

Options :
  • --batch
  • --silent
  • --verbose

Ligne de commande :
elasticsearch-plugin install file:///path/to/plugin.zip
Description :

Installe un plugin depuis un fichier local

Options :
  • --batch

Ligne de commande :
elasticsearch-plugin install https://example.com/plugin.zip
Description :

Installe un plugin depuis une URL

Options :
  • --batch

Ligne de commande :
elasticsearch-plugin remove analysis-icu
Description :

Désinstalle un plugin

Options :
  • --silent
  • --verbose

Ligne de commande :
elasticsearch-certutil
Description :

Gère les certificats pour Elasticsearch

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

Ligne de commande :
elasticsearch-certutil ca
Description :

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

Options :
  • --pem
  • --days
  • --keysize
  • --out
  • --pass
  • --silent

Ligne de commande :
elasticsearch-certutil ca --pem --out ca.zip
Description :

Génère une CA au format PEM

Options :
  • --pem
  • --out

Ligne de commande :
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

Ligne de commande :
elasticsearch-certutil http
Description :

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

Options :
  • --dns
  • --ip
  • --out
  • --pass
  • --silent

Ligne de commande :
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

Ligne de commande :
elasticsearch-keystore create
Description :

Crée un nouveau keystore

Options :
  • -p
  • --stdin
  • -f
  • --force

Ligne de commande :
elasticsearch-keystore list
Description :

Liste les entrées du keystore

Ligne de commande :
elasticsearch-keystore add s3.client.default.access_key
Description :

Ajoute une clé au keystore

Options :
  • --stdin
  • -x
  • --force

Ligne de commande :
elasticsearch-keystore remove s3.client.default.access_key
Description :

Supprime une clé du keystore

Ligne de commande :
elasticsearch-keystore show s3.client.default.access_key
Description :

Affiche la valeur d'une clé

Ligne de commande :
elasticsearch-node
Description :

Gère les nœuds Elasticsearch (maintenance)

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

Ligne de commande :
elasticsearch-node repurpose
Description :

Change le rôle d'un nœud

Ligne de commande :
elasticsearch-node unsafe-bootstrap
Description :

Force le bootstrap d'un cluster (urgence)

Ligne de commande :
elasticsearch-node detach-cluster
Description :

Détache un nœud du cluster

Ligne de commande :
elasticsearch-shard
Description :

Gère les shards Elasticsearch

Options :
  • remove-corrupted-shard
  • --help
  • -h

Ligne de commande :
elasticsearch-shard remove-corrupted-shard --index monindex --shard-id 0
Description :

Supprime un shard corrompu

Options :
  • --index
  • --shard-id

Ligne de commande :
elasticsearch-saml-metadata
Description :

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

Options :
  • --realm
  • --out
  • --help

Ligne de commande :
elasticsearch-saml-metadata --realm saml1 --out metadata.xml
Description :

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

Options :
  • --realm
  • --out

Ligne de commande :
elasticsearch-setup-passwords
Description :

Initialise les mots de passe des utilisateurs built-in

Options :
  • auto
  • interactive
  • --help
  • -h
  • --batch

Ligne de commande :
elasticsearch-setup-passwords auto
Description :

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

Options :
  • --batch

Ligne de commande :
elasticsearch-setup-passwords interactive
Description :

Définit les mots de passe interactivement

Ligne de commande :
elasticsearch-users
Description :

Gère les utilisateurs du file realm

Options :
  • useradd
  • userdel
  • passwd
  • roles
  • list
  • --help
  • -h

Ligne de commande :
elasticsearch-users useradd monuser -p monmotdepasse -r superuser
Description :

Crée un utilisateur avec rôle

Options :
  • -p
  • --password
  • -r
  • --role

Ligne de commande :
elasticsearch-users userdel monuser
Description :

Supprime un utilisateur

Ligne de commande :
elasticsearch-users passwd monuser -p nouveau
Description :

Change le mot de passe d'un utilisateur

Options :
  • -p
  • --password

Ligne de commande :
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

Ligne de commande :
elasticsearch-users list
Description :

Liste tous les utilisateurs

Ligne de commande :
elasticsearch-syskeygen
Description :

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

Options :
  • --help
  • -h

Ligne de commande :
curl -X GET "localhost:9200/"
Description :

Vérifie que Elasticsearch est en ligne

Options :
  • -u
  • --user
  • -k
  • --insecure
  • -H
  • --header

Ligne de commande :
curl -X GET "localhost:9200/_cluster/health"
Description :

Affiche la santé du cluster

Options :
  • ?pretty
  • ?format=json
  • ?level=indices
  • ?level=shards

Ligne de commande :
curl -X GET "localhost:9200/_cluster/health?pretty"
Description :

Santé du cluster formatée

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

État complet du cluster

Options :
  • ?pretty
  • ?filter_path=metadata.indices

Ligne de commande :
curl -X GET "localhost:9200/_cluster/stats"
Description :

Statistiques du cluster

Options :
  • ?pretty
  • ?human

Ligne de commande :
curl -X GET "localhost:9200/_cluster/settings"
Description :

Affiche les paramètres du cluster

Options :
  • ?pretty
  • ?flat_settings=true
  • ?include_defaults=true

Ligne de commande :
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

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

Tâches en attente dans le cluster

Options :
  • ?pretty

Ligne de commande :
curl -X GET "localhost:9200/_nodes"
Description :

Informations sur tous les nœuds

Options :
  • ?pretty
  • ?filter_path=nodes.*.name
  • ?metric=os,process

Ligne de commande :
curl -X GET "localhost:9200/_nodes/stats"
Description :

Statistiques des nœuds

Options :
  • ?pretty
  • ?metric=indices,jvm
  • ?human

Ligne de commande :
curl -X GET "localhost:9200/_nodes/hot_threads"
Description :

Threads les plus actifs

Options :
  • ?threads=5
  • ?interval=2s
  • ?type=cpu

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
curl -X GET "localhost:9200/_cat/shards?v"
Description :

Liste tous les shards

Options :
  • ?v
  • &h=index,shard,prirep,state,node

Ligne de commande :
curl -X GET "localhost:9200/_cat/segments?v"
Description :

Informations sur les segments Lucene

Options :
  • ?v
  • &h=index,shard,segment,size,size.memory

Ligne de commande :
curl -X GET "localhost:9200/_cat/recovery?v"
Description :

État de la récupération des shards

Options :
  • ?v
  • &active_only=true

Ligne de commande :
curl -X GET "localhost:9200/_cat/health?v"
Description :

Santé du cluster (format cat)

Options :
  • ?v
  • &ts=false

Ligne de commande :
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

Ligne de commande :
curl -X GET "localhost:9200/_cat/thread_pool?v"
Description :

État des pools de threads

Options :
  • ?v
  • &h=node,name,active,rejected,completed,queue

Ligne de commande :
curl -X GET "localhost:9200/_cat/tasks?v"
Description :

Tâches en cours d'exécution

Options :
  • ?v
  • &detailed

Ligne de commande :
curl -X GET "localhost:9200/_cat/templates?v"
Description :

Liste les templates d'index

Options :
  • ?v
  • &s=name

Ligne de commande :
curl -X GET "localhost:9200/_cat/plugins?v"
Description :

Liste les plugins installés

Options :
  • ?v

Ligne de commande :
curl -X GET "localhost:9200/_cat/fielddata?v"
Description :

Utilisation de la mémoire fielddata

Options :
  • ?v
  • &fields=*

Ligne de commande :
curl -X GET "localhost:9200/_cat/count/monindex?v"
Description :

Nombre de documents dans un index

Options :
  • ?v

Ligne de commande :
curl -X GET "localhost:9200/_cat/master?v"
Description :

Affiche le nœud master

Options :
  • ?v

Ligne de commande :
curl -X GET "localhost:9200/_cat/nodeattrs?v"
Description :

Attributs personnalisés des nœuds

Options :
  • ?v

Ligne de commande :
curl -X GET "localhost:9200/_cat/repositories?v"
Description :

Liste les repositories de snapshot

Options :
  • ?v

Ligne de commande :
curl -X GET "localhost:9200/_cat/snapshots/mon_repo?v"
Description :

Liste les snapshots dans un repository

Options :
  • ?v
  • &s=id

Ligne de commande :
curl -X GET "localhost:9200/_cat/aliases?v"
Description :

Liste les alias d'index

Options :
  • ?v
  • &h=alias,index

Ligne de commande :
curl -X GET "localhost:9200/_cat/ml/anomaly_detectors?v"
Description :

Liste les jobs de détection d'anomalies

Options :
  • ?v

Ligne de commande :
curl -X GET "localhost:9200/_cat/transforms?v"
Description :

Liste les transforms

Options :
  • ?v

Ligne de commande :
curl -X PUT "localhost:9200/monindex"
Description :

Crée un index

Options :
  • -d
  • --data

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
curl -X DELETE "localhost:9200/monindex"
Description :

Supprime un index

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

Supprime plusieurs index par pattern

Ligne de commande :
curl -X GET "localhost:9200/monindex"
Description :

Récupère les informations d'un index

Options :
  • ?pretty

Ligne de commande :
curl -X GET "localhost:9200/monindex/_mapping"
Description :

Affiche le mapping d'un index

Options :
  • ?pretty

Ligne de commande :
curl -X GET "localhost:9200/monindex/_settings"
Description :

Affiche les paramètres d'un index

Options :
  • ?pretty
  • ?flat_settings=true

Ligne de commande :
curl -X GET "localhost:9200/monindex/_stats"
Description :

Statistiques d'un index

Options :
  • ?pretty

Ligne de commande :
curl -X GET "localhost:9200/monindex/_segments"
Description :

Segments d'un index

Options :
  • ?pretty
  • ?verbose

Ligne de commande :
curl -X POST "localhost:9200/monindex/_close"
Description :

Ferme un index

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

Ouvre un index fermé

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

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

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

Dégèle un index

Ligne de commande :
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

Ligne de commande :
curl -X POST "localhost:9200/monindex/_refresh"
Description :

Rafraîchit un index (rend les documents visibles)

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

Flushe les transactions vers le disque

Options :
  • ?force
  • ?wait_if_ongoing

Ligne de commande :
curl -X POST "localhost:9200/monindex/_clear_cache"
Description :

Vide les caches de l'index

Options :
  • ?fielddata=true
  • ?query=true
  • ?request=true

Ligne de commande :
curl -X POST "localhost:9200/monindex/_rollover"
Description :

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

Options :
  • -d
  • --data

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

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

Clone un index

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

Crée un alias pour un index

Ligne de commande :
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)

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

Supprime un alias

Ligne de commande :
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

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

Affiche les index d'un alias

Ligne de commande :
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

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

Récupère un template

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

Supprime un template

Ligne de commande :
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)

Ligne de commande :
curl -X GET "localhost:9200/_index_template"
Description :

Liste les templates composables

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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=*

Ligne de commande :
curl -X GET "localhost:9200/monindex/_doc/1?_source=name,age"
Description :

Récupère uniquement certains champs

Options :
  • ?_source
  • ?_source_includes
  • ?_source_excludes

Ligne de commande :
curl -X HEAD "localhost:9200/monindex/_doc/1"
Description :

Vérifie si un document existe

Ligne de commande :
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)

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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)

Ligne de commande :
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

Ligne de commande :
curl -X DELETE "localhost:9200/monindex/_doc/1"
Description :

Supprime un document

Options :
  • ?routing
  • ?refresh
  • ?version

Ligne de commande :
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

Ligne de commande :
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

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

Recherche full-text (match)

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

Recherche exacte (term)

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

Recherche sur plusieurs valeurs (terms)

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"prefix": {"name": "Jo"}}}'
Description :

Recherche par préfixe

Options :
  • prefix

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"exists": {"field": "email"}}}'
Description :

Documents ayant un champ

Options :
  • exists

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

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

Continue un scroll

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

Supprime un scroll

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

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

Options :
  • ?keep_alive

Ligne de commande :
curl -X DELETE "localhost:9200/_pit" -H 'Content-Type: application/json' -d'{"id": "..."}'
Description :

Supprime un PIT

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

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

Compte les documents sans les retourner

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

Explique pourquoi un document correspond

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
curl -X GET "localhost:9200/_tasks?actions=*reindex&detailed"
Description :

Surveille les tâches de réindexation

Options :
  • ?actions
  • &detailed
  • &group_by

Ligne de commande :
curl -X POST "localhost:9200/_tasks/task_id/_cancel"
Description :

Annule une tâche en cours

Ligne de commande :
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

Ligne de commande :
curl -X GET "localhost:9200/_snapshot/mon_repo"
Description :

Vérifie un repository

Ligne de commande :
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

Ligne de commande :
curl -X GET "localhost:9200/_snapshot/mon_repo/snapshot1"
Description :

Informations sur un snapshot

Options :
  • ?verbose

Ligne de commande :
curl -X GET "localhost:9200/_snapshot/mon_repo/snapshot1/_status"
Description :

Statut d'un snapshot en cours

Ligne de commande :
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

Ligne de commande :
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

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

Supprime un snapshot

Ligne de commande :
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)

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

Exécute immédiatement une politique SLM

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

Liste les politiques SLM

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

Liste les politiques ILM (Index Lifecycle Management)

Ligne de commande :
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

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

Relance une action ILM en échec

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

Explique l'état ILM d'un index

Ligne de commande :
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

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

Liste les utilisateurs

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

Supprime un utilisateur

Ligne de commande :
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

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

Liste les rôles

Ligne de commande :
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

Ligne de commande :
curl -X GET "localhost:9200/_security/api_key"
Description :

Récupère les clés API

Options :
  • ?owner=true

Ligne de commande :
curl -X DELETE "localhost:9200/_security/api_key" -H 'Content-Type: application/json' -d'{"name": "mon_api_key"}'
Description :

Révoque une clé API

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

Crée un token de service

Ligne de commande :
curl -X GET "localhost:9200/_license"
Description :

Affiche la licence

Options :
  • ?local

Ligne de commande :
curl -X POST "localhost:9200/_license/start_trial?acknowledge=true"
Description :

Démarre l'essai de 30 jours

Options :
  • ?acknowledge

Ligne de commande :
curl -X GET "localhost:9200/_xpack"
Description :

Informations sur les fonctionnalités X-Pack

Options :
  • ?categories
  • &human

Ligne de commande :
curl -X GET "localhost:9200/_xpack/usage"
Description :

Statistiques d'utilisation X-Pack

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

Flush synchronisé sur tous les index

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

Flush synchronisé sur tous les index (explicite)

Ligne de commande :
curl -X POST "localhost:9200/_synced_flush"
Description :

Alias de flush synchronisé

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

Vide tous les caches

Options :
  • ?fielddata
  • &query
  • &request

Ligne de commande :
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

Ligne de commande :
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

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

Récupère un script stocké

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

Supprime un script stocké

Ligne de commande :
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

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

Liste les pipelines

Ligne de commande :
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

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

Supprime un pipeline

Ligne de commande :
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

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

Exécute une politique d'enrichissement

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

Liste les politiques d'enrichissement

Ligne de commande :
curl -X GET "localhost:9200/_data_stream"
Description :

Liste les data streams

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

Crée un data stream

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

Supprime un data stream

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

Statistiques des data streams

Ligne de commande :
curl -X GET "localhost:9200/_transform"
Description :

Liste les transforms

Ligne de commande :
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

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

Démarre un transform

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

Arrête un transform

Options :
  • ?force

Ligne de commande :
curl -X GET "localhost:9200/_transform/mon_transform/_stats"
Description :

Statistiques d'un transform

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

Supprime un transform

Options :
  • ?force

Ligne de commande :
curl -X GET "localhost:9200/_ml/info"
Description :

Informations sur le Machine Learning

Ligne de commande :
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

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

Ouvre un job ML

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

Ferme un job ML

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

Démarre un job ML

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

Arrête un job ML

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

Statistiques d'un job ML

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

Liste les datafeeds ML

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

Liste les filtres ML

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

Liste les calendriers ML

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

Liste les watches (alertes)

Ligne de commande :
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

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

Exécute manuellement une watch

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

Supprime une watch

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

Statistiques Watcher

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

Démarre Watcher

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

Arrête Watcher

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

Explore les relations (Graph)

Ligne de commande :
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

Ligne de commande :
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

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

Statistiques SQL

Ligne de commande :
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)

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

Statistiques EQL

Ligne de commande :
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

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

Démarre un job de rollup

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

Informations sur un job de rollup

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

Récupère les données rollup

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

Statistiques des snapshots consultables

Options :
  • ?pretty

Ligne de commande :
curl -X POST "localhost:9200/_migration/deprecations"
Description :

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

Options :
  • ?index

Ligne de commande :
curl -X POST "localhost:9200/_migration/upgrade/monindex"
Description :

Met à niveau un index vers la version actuelle

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

Met à niveau les features après upgrade

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
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

Ligne de commande :
curl -X POST "localhost:9200/_mtermvectors" -H 'Content-Type: application/json' -d'{"docs": [{"_index": "monindex", "_id": "1", "fields": ["description"]}]}'
Description :

Multi termvectors

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

Capacités des champs à travers les index

Options :
  • ?fields

Ligne de commande :
curl -X GET "localhost:9200/_nodes/reload_secure_settings"
Description :

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

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

Informations sur les certificats SSL

Options :
  • ?pretty

Ligne de commande :
curl -X GET "localhost:9200/_autoscaling/policy"
Description :

Liste les politiques d'autoscaling

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

Capacité actuelle d'autoscaling

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

Affiche le mapping des logs Elasticsearch