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.
elasticsearch
Démarre le serveur Elasticsearch
-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
Démarre en arrière-plan avec fichier PID
-d-p
elasticsearch -Ecluster.name=moncluster -Enode.name=node1
Démarre avec paramètres en ligne de commande
-E
elasticsearch-plugin
Gère les plugins Elasticsearch
listinstallremove--help-h--silent-s--verbose-v--batch
elasticsearch-plugin list
Liste les plugins installés
--help
elasticsearch-plugin install analysis-icu
Installe le plugin ICU
--batch--silent--verbose
elasticsearch-plugin install file:///path/to/plugin.zip
Installe un plugin depuis un fichier local
--batch
elasticsearch-plugin install https://example.com/plugin.zip
Installe un plugin depuis une URL
--batch
elasticsearch-plugin remove analysis-icu
Désinstalle un plugin
--silent--verbose
elasticsearch-certutil
Gère les certificats pour Elasticsearch
cacertcsrhttp--help-h--silent-s
elasticsearch-certutil ca
Génère une autorité de certification (CA)
--pem--days--keysize--out--pass--silent
elasticsearch-certutil ca --pem --out ca.zip
Génère une CA au format PEM
--pem--out
elasticsearch-certutil cert --ca ca.zip --dns localhost --ip 127.0.0.1 --out cert.zip
Génère un certificat signé par la CA
--ca--dns--ip--name--out--pass--multiple--keysize--days
elasticsearch-certutil http
Génère des certificats pour HTTP (REST API)
--dns--ip--out--pass--silent
elasticsearch-keystore
Gère le keystore sécurisé Elasticsearch
createlistaddremoveshowpasswdhas-passwd--help-h--silent-s--verbose-v-f--force
elasticsearch-keystore create
Crée un nouveau keystore
-p--stdin-f--force
elasticsearch-keystore list
Liste les entrées du keystore
elasticsearch-keystore add s3.client.default.access_key
Ajoute une clé au keystore
--stdin-x--force
elasticsearch-keystore remove s3.client.default.access_key
Supprime une clé du keystore
elasticsearch-keystore show s3.client.default.access_key
Affiche la valeur d'une clé
elasticsearch-node
Gère les nœuds Elasticsearch (maintenance)
repurposeunsafe-bootstrapdetach-clusteroverride-versionremove-settings--help-h
elasticsearch-node repurpose
Change le rôle d'un nœud
elasticsearch-node unsafe-bootstrap
Force le bootstrap d'un cluster (urgence)
elasticsearch-node detach-cluster
Détache un nœud du cluster
elasticsearch-shard
Gère les shards Elasticsearch
remove-corrupted-shard--help-h
elasticsearch-shard remove-corrupted-shard --index monindex --shard-id 0
Supprime un shard corrompu
--index--shard-id
elasticsearch-saml-metadata
Génère les métadonnées SAML
--realm--out--help
elasticsearch-saml-metadata --realm saml1 --out metadata.xml
Génère les métadonnées pour un realm SAML
--realm--out
elasticsearch-setup-passwords
Initialise les mots de passe des utilisateurs built-in
autointeractive--help-h--batch
elasticsearch-setup-passwords auto
Génère des mots de passe aléatoires
--batch
elasticsearch-setup-passwords interactive
Définit les mots de passe interactivement
elasticsearch-users
Gère les utilisateurs du file realm
useradduserdelpasswdroleslist--help-h
elasticsearch-users useradd monuser -p monmotdepasse -r superuser
Crée un utilisateur avec rôle
-p--password-r--role
elasticsearch-users userdel monuser
Supprime un utilisateur
elasticsearch-users passwd monuser -p nouveau
Change le mot de passe d'un utilisateur
-p--password
elasticsearch-users roles monuser -a kibana_admin -r monitoring_user
Ajoute/supprime des rôles (-a = add, -r = remove)
-a--add-r--remove
elasticsearch-users list
Liste tous les utilisateurs
elasticsearch-syskeygen
Génère une clé système pour le chiffrement
--help-h
curl -X GET "localhost:9200/"
Vérifie que Elasticsearch est en ligne
-u--user-k--insecure-H--header
curl -X GET "localhost:9200/_cluster/health"
Affiche la santé du cluster
?pretty?format=json?level=indices?level=shards
curl -X GET "localhost:9200/_cluster/health?pretty"
Santé du cluster formatée
curl -X GET "localhost:9200/_cluster/state"
État complet du cluster
?pretty?filter_path=metadata.indices
curl -X GET "localhost:9200/_cluster/stats"
Statistiques du cluster
?pretty?human
curl -X GET "localhost:9200/_cluster/settings"
Affiche les paramètres du cluster
?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"}}'
Modifie les paramètres du cluster
curl -X GET "localhost:9200/_cluster/pending_tasks"
Tâches en attente dans le cluster
?pretty
curl -X GET "localhost:9200/_nodes"
Informations sur tous les nœuds
?pretty?filter_path=nodes.*.name?metric=os,process
curl -X GET "localhost:9200/_nodes/stats"
Statistiques des nœuds
?pretty?metric=indices,jvm?human
curl -X GET "localhost:9200/_nodes/hot_threads"
Threads les plus actifs
?threads=5?interval=2s?type=cpu
curl -X GET "localhost:9200/_cat/nodes?v"
Liste les nœuds (format cat)
?v&h=name,ip,heap.percent,ram.percent,load&s=name
curl -X GET "localhost:9200/_cat/indices?v"
Liste tous les index
?v&s=index&h=index,health,status,pri,rep,docs.count,store.size
curl -X GET "localhost:9200/_cat/shards?v"
Liste tous les shards
?v&h=index,shard,prirep,state,node
curl -X GET "localhost:9200/_cat/segments?v"
Informations sur les segments Lucene
?v&h=index,shard,segment,size,size.memory
curl -X GET "localhost:9200/_cat/recovery?v"
État de la récupération des shards
?v&active_only=true
curl -X GET "localhost:9200/_cat/health?v"
Santé du cluster (format cat)
?v&ts=false
curl -X GET "localhost:9200/_cat/allocation?v"
Allocation des shards par nœud
?v&h=node,shards,disk.percent,disk.used,disk.avail
curl -X GET "localhost:9200/_cat/thread_pool?v"
État des pools de threads
?v&h=node,name,active,rejected,completed,queue
curl -X GET "localhost:9200/_cat/tasks?v"
Tâches en cours d'exécution
?v&detailed
curl -X GET "localhost:9200/_cat/templates?v"
Liste les templates d'index
?v&s=name
curl -X GET "localhost:9200/_cat/plugins?v"
Liste les plugins installés
?v
curl -X GET "localhost:9200/_cat/fielddata?v"
Utilisation de la mémoire fielddata
?v&fields=*
curl -X GET "localhost:9200/_cat/count/monindex?v"
Nombre de documents dans un index
?v
curl -X GET "localhost:9200/_cat/master?v"
Affiche le nœud master
?v
curl -X GET "localhost:9200/_cat/nodeattrs?v"
Attributs personnalisés des nœuds
?v
curl -X GET "localhost:9200/_cat/repositories?v"
Liste les repositories de snapshot
?v
curl -X GET "localhost:9200/_cat/snapshots/mon_repo?v"
Liste les snapshots dans un repository
?v&s=id
curl -X GET "localhost:9200/_cat/aliases?v"
Liste les alias d'index
?v&h=alias,index
curl -X GET "localhost:9200/_cat/ml/anomaly_detectors?v"
Liste les jobs de détection d'anomalies
?v
curl -X GET "localhost:9200/_cat/transforms?v"
Liste les transforms
?v
curl -X PUT "localhost:9200/monindex"
Crée un index
-d--data
curl -X PUT "localhost:9200/monindex" -H 'Content-Type: application/json' -d'{"settings": {"number_of_shards": 3, "number_of_replicas": 1}}'
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"}}}}'
Crée un index avec mappings
curl -X DELETE "localhost:9200/monindex"
Supprime un index
curl -X DELETE "localhost:9200/index-*"
Supprime plusieurs index par pattern
curl -X GET "localhost:9200/monindex"
Récupère les informations d'un index
?pretty
curl -X GET "localhost:9200/monindex/_mapping"
Affiche le mapping d'un index
?pretty
curl -X GET "localhost:9200/monindex/_settings"
Affiche les paramètres d'un index
?pretty?flat_settings=true
curl -X GET "localhost:9200/monindex/_stats"
Statistiques d'un index
?pretty
curl -X GET "localhost:9200/monindex/_segments"
Segments d'un index
?pretty?verbose
curl -X POST "localhost:9200/monindex/_close"
Ferme un index
curl -X POST "localhost:9200/monindex/_open"
Ouvre un index fermé
curl -X POST "localhost:9200/monindex/_freeze"
Gèle un index (réduit mémoire)
curl -X POST "localhost:9200/monindex/_unfreeze"
Dégèle un index
curl -X POST "localhost:9200/monindex/_forcemerge?max_num_segments=1"
Force la fusion des segments
?max_num_segments?only_expunge_deletes?flush
curl -X POST "localhost:9200/monindex/_refresh"
Rafraîchit un index (rend les documents visibles)
curl -X POST "localhost:9200/monindex/_flush"
Flushe les transactions vers le disque
?force?wait_if_ongoing
curl -X POST "localhost:9200/monindex/_clear_cache"
Vide les caches de l'index
?fielddata=true?query=true?request=true
curl -X POST "localhost:9200/monindex/_rollover"
Crée un nouvel index quand l'actuel est plein
-d--data
curl -X POST "localhost:9200/monindex/_rollover/monindex-000002" -H 'Content-Type: application/json' -d'{"conditions": {"max_age": "7d", "max_docs": 1000000}}'
Rollover avec conditions
curl -X POST "localhost:9200/monindex/_shrink/monindex-reduit" -H 'Content-Type: application/json' -d'{"settings": {"index.number_of_shards": 1}}'
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}}'
Augmente le nombre de shards
curl -X POST "localhost:9200/monindex/_clone/monindex-clone"
Clone un index
curl -X PUT "localhost:9200/monindex/_alias/monalias"
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"}}]}'
Gère les alias (actions multiples)
curl -X POST "localhost:9200/_aliases" -H 'Content-Type: application/json' -d'{"actions": [{"remove": {"index": "monindex", "alias": "monalias"}}]}'
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"}}}}]}'
Alias avec filtre
curl -X GET "localhost:9200/_alias/monalias"
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}}'
Crée un template d'index
curl -X GET "localhost:9200/_template/montemplate"
Récupère un template
curl -X DELETE "localhost:9200/_template/montemplate"
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}}}'
Crée un template d'index (nouvelle API composable)
curl -X GET "localhost:9200/_index_template"
Liste les templates composables
curl -X PUT "localhost:9200/_component_template/moncomponent" -H 'Content-Type: application/json' -d'{"template": {"mappings": {"properties": {"@timestamp": {"type": "date"}}}}}'
Crée un component template
curl -X POST "localhost:9200/monindex/_doc" -H 'Content-Type: application/json' -d'{"name": "John", "age": 30}'
Indexe un document (ID auto-généré)
?pipeline?routing?refresh
curl -X PUT "localhost:9200/monindex/_doc/1" -H 'Content-Type: application/json' -d'{"name": "John", "age": 30}'
Indexe un document avec ID spécifique
?op_type=create?version=2?version_type=external
curl -X POST "localhost:9200/_bulk" -H 'Content-Type: application/json' --data-binary @bulk.json
Indexe en masse (bulk API)
?pipeline?routing?refresh
curl -X GET "localhost:9200/monindex/_doc/1"
Récupère un document par ID
?pretty?_source=true?_source_includes=name,age?_source_excludes=*
curl -X GET "localhost:9200/monindex/_doc/1?_source=name,age"
Récupère uniquement certains champs
?_source?_source_includes?_source_excludes
curl -X HEAD "localhost:9200/monindex/_doc/1"
Vérifie si un document existe
curl -X GET "localhost:9200/monindex/_mget" -H 'Content-Type: application/json' -d'{"ids": ["1", "2", "3"]}'
Récupère plusieurs documents (multi-get)
curl -X POST "localhost:9200/monindex/_update/1" -H 'Content-Type: application/json' -d'{"doc": {"age": 31}}'
Met à jour partiellement un document
?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}}}'
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}'
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"}}}'
Met à jour par requête
?conflicts=proceed?wait_for_completion=false?scroll_size=1000
curl -X DELETE "localhost:9200/monindex/_doc/1"
Supprime un document
?routing?refresh?version
curl -X POST "localhost:9200/monindex/_delete_by_query" -H 'Content-Type: application/json' -d'{"query": {"match": {"name": "John"}}}'
Supprime par requête
?conflicts=proceed?scroll_size=1000
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"match_all": {}}}'
Recherche tous les documents
?pretty?size=10?from=0?timeout=30s
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"match": {"name": "John"}}}'
Recherche full-text (match)
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"term": {"status": "active"}}}'
Recherche exacte (term)
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"terms": {"tags": ["elasticsearch", "database"]}}}'
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}}}}'
Recherche par plage (range)
gtgteltlteboostformattime_zone
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"bool": {"must": [{"match": {"name": "John"}}], "filter": [{"term": {"status": "active"}}]}}}'
Requête booléenne
mustmust_notshouldfilter
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"multi_match": {"query": "elasticsearch", "fields": ["title^3", "content"]}}}'
Recherche sur plusieurs champs
fieldstypetie_breakeroperatorminimum_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"}}}'
Requête avec syntaxe Lucene
querydefault_fieldallow_leading_wildcardanalyze_wildcardlenient
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"prefix": {"name": "Jo"}}}'
Recherche par préfixe
prefix
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"wildcard": {"name": "J*"}}}'
Recherche avec wildcard
wildcardboostcase_insensitive
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"fuzzy": {"name": {"value": "Jonh", "fuzziness": "AUTO"}}}}'
Recherche approximative (fuzzy)
fuzzinessmax_expansionsprefix_lengthtranspositions
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"regexp": {"name": "J.*n"}}}'
Recherche par expression régulière
regexpflagsmax_determinized_states
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"exists": {"field": "email"}}}'
Documents ayant un champ
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}}}}'
Recherche géographique par distance
geo_distancegeo_bounding_boxgeo_polygongeo_shape
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"match_all": {}}, "sort": [{"age": "desc"}, {"name": "asc"}]}'
Tri des résultats
sort
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"match_all": {}}, "from": 10, "size": 10}'
Pagination (from/size)
fromsize
curl -X POST "localhost:9200/monindex/_search?scroll=1m" -H 'Content-Type: application/json' -d'{"query": {"match_all": {}}, "size": 1000}'
Scroll API (pagination profonde)
?scroll
curl -X POST "localhost:9200/_search/scroll" -H 'Content-Type: application/json' -d'{"scroll": "1m", "scroll_id": "..."}'
Continue un scroll
curl -X DELETE "localhost:9200/_search/scroll" -H 'Content-Type: application/json' -d'{"scroll_id": "..."}'
Supprime un scroll
curl -X POST "localhost:9200/monindex/_pit?keep_alive=1m"
Crée un Point In Time (PIT) pour pagination
?keep_alive
curl -X DELETE "localhost:9200/_pit" -H 'Content-Type: application/json' -d'{"id": "..."}'
Supprime un PIT
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"match": {"name": "John"}}, "highlight": {"fields": {"name": {}}}}'
Surlignage des résultats
highlight
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"size": 0, "aggs": {"avg_age": {"avg": {"field": "age"}}}}'
Agrégation moyenne
aggssize
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"size": 0, "aggs": {"by_city": {"terms": {"field": "city.keyword"}}}}'
Agrégation par termes (group by)
termssizeordermin_doc_countincludeexclude
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"size": 0, "aggs": {"age_histogram": {"histogram": {"field": "age", "interval": 10}}}}'
Agrégation histogramme
histogramintervalmin_doc_countextended_boundsorder
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"size": 0, "aggs": {"age_stats": {"stats": {"field": "age"}}}}'
Agrégation statistiques (min, max, avg, sum, count)
statsextended_statspercentilespercentile_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"}}}}}}'
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"}]}}}}'
Agrégation top_hits
top_hitssizesort_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"}}}}'
Suggestion de correction orthographique
suggesttermphrasecompletion
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"profile": true, "query": {"match": {"name": "John"}}}'
Profile une requête (debug performance)
profile
curl -X POST "localhost:9200/monindex/_search?request_cache=false" -H 'Content-Type: application/json' -d'{"query": {"match": {"name": "John"}}}'
Désactive le cache de requête
?request_cache
curl -X POST "localhost:9200/monindex/_search" -H 'Content-Type: application/json' -d'{"query": {"match": {"name": "John"}}, "track_total_hits": true}'
Force le comptage exact des hits
track_total_hits
curl -X POST "localhost:9200/monindex/_count" -H 'Content-Type: application/json' -d'{"query": {"match": {"name": "John"}}}'
Compte les documents sans les retourner
curl -X POST "localhost:9200/monindex/_explain/1" -H 'Content-Type: application/json' -d'{"query": {"match": {"name": "John"}}}'
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"}}}'
Valide une requête sans l'exécuter
?explain?rewrite
curl -X POST "localhost:9200/_reindex" -H 'Content-Type: application/json' -d'{"source": {"index": "oldindex"}, "dest": {"index": "newindex"}}'
Réindexe les documents d'un index à un autre
?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"}}'
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"}}'
Réindexe depuis un cluster distant
remote
curl -X GET "localhost:9200/_tasks?actions=*reindex&detailed"
Surveille les tâches de réindexation
?actions&detailed&group_by
curl -X POST "localhost:9200/_tasks/task_id/_cancel"
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"}}'
Crée un repository de snapshots
typesettings
curl -X GET "localhost:9200/_snapshot/mon_repo"
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}'
Crée un snapshot
?wait_for_completion?master_timeout
curl -X GET "localhost:9200/_snapshot/mon_repo/snapshot1"
Informations sur un snapshot
?verbose
curl -X GET "localhost:9200/_snapshot/mon_repo/snapshot1/_status"
Statut d'un snapshot en cours
curl -X POST "localhost:9200/_snapshot/mon_repo/snapshot1/_restore" -H 'Content-Type: application/json' -d'{"indices": "monindex"}'
Restaure un snapshot
?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"}'
Restaure avec renommage
curl -X DELETE "localhost:9200/_snapshot/mon_repo/snapshot1"
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": ["*"]}}'
Crée une politique de snapshot automatique (SLM)
curl -X POST "localhost:9200/_slm/policy/nightly-backup/_execute"
Exécute immédiatement une politique SLM
curl -X GET "localhost:9200/_slm/policy"
Liste les politiques SLM
curl -X GET "localhost:9200/_ilm/policy"
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": {}}}}}'
Crée une politique ILM
curl -X POST "localhost:9200/monindex/_ilm/retry"
Relance une action ILM en échec
curl -X GET "localhost:9200/monindex/_ilm/explain"
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"]}'
Crée un utilisateur via API
curl -X GET "localhost:9200/_security/user"
Liste les utilisateurs
curl -X DELETE "localhost:9200/_security/user/monuser"
Supprime un utilisateur
curl -X POST "localhost:9200/_security/role/monrole" -H 'Content-Type: application/json' -d'{"cluster": ["all"], "indices": [{"names": ["*"], "privileges": ["read"]}]}'
Crée un rôle
curl -X GET "localhost:9200/_security/role"
Liste les rôles
curl -X POST "localhost:9200/_security/api_key" -H 'Content-Type: application/json' -d'{"name": "mon_api_key", "role_descriptors": {}}'
Crée une clé API
?refresh
curl -X GET "localhost:9200/_security/api_key"
Récupère les clés API
?owner=true
curl -X DELETE "localhost:9200/_security/api_key" -H 'Content-Type: application/json' -d'{"name": "mon_api_key"}'
Révoque une clé API
curl -X POST "localhost:9200/_security/service/elastic/kibana/credential/token/kibana_token"
Crée un token de service
curl -X GET "localhost:9200/_license"
Affiche la licence
?local
curl -X POST "localhost:9200/_license/start_trial?acknowledge=true"
Démarre l'essai de 30 jours
?acknowledge
curl -X GET "localhost:9200/_xpack"
Informations sur les fonctionnalités X-Pack
?categories&human
curl -X GET "localhost:9200/_xpack/usage"
Statistiques d'utilisation X-Pack
curl -X POST "localhost:9200/_flush/synced"
Flush synchronisé sur tous les index
curl -X POST "localhost:9200/_all/_flush/synced"
Flush synchronisé sur tous les index (explicite)
curl -X POST "localhost:9200/_synced_flush"
Alias de flush synchronisé
curl -X POST "localhost:9200/_cache/clear"
Vide tous les caches
?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}}}'
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++"}}'
Stocke un script
curl -X GET "localhost:9200/_scripts/mon_script"
Récupère un script stocké
curl -X DELETE "localhost:9200/_scripts/mon_script"
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}}]}'
Crée un pipeline d'ingestion
curl -X GET "localhost:9200/_ingest/pipeline"
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"}}]}'
Simule un pipeline
curl -X DELETE "localhost:9200/_ingest/pipeline/mon_pipeline"
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"]}}'
Crée une politique d'enrichissement
curl -X POST "localhost:9200/_enrich/policy/mon_policy/_execute"
Exécute une politique d'enrichissement
curl -X GET "localhost:9200/_enrich/policy"
Liste les politiques d'enrichissement
curl -X GET "localhost:9200/_data_stream"
Liste les data streams
curl -X PUT "localhost:9200/_data_stream/mon_data_stream"
Crée un data stream
curl -X DELETE "localhost:9200/_data_stream/mon_data_stream"
Supprime un data stream
curl -X GET "localhost:9200/_data_stream/_stats"
Statistiques des data streams
curl -X GET "localhost:9200/_transform"
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"}}}}}'
Crée un transform
curl -X POST "localhost:9200/_transform/mon_transform/_start"
Démarre un transform
curl -X POST "localhost:9200/_transform/mon_transform/_stop"
Arrête un transform
?force
curl -X GET "localhost:9200/_transform/mon_transform/_stats"
Statistiques d'un transform
curl -X DELETE "localhost:9200/_transform/mon_transform"
Supprime un transform
?force
curl -X GET "localhost:9200/_ml/info"
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"}}'
Crée un job de détection d'anomalies
curl -X POST "localhost:9200/_ml/anomaly_detectors/mon_job/_open"
Ouvre un job ML
curl -X POST "localhost:9200/_ml/anomaly_detectors/mon_job/_close"
Ferme un job ML
curl -X POST "localhost:9200/_ml/anomaly_detectors/mon_job/_start"
Démarre un job ML
curl -X POST "localhost:9200/_ml/anomaly_detectors/mon_job/_stop"
Arrête un job ML
curl -X GET "localhost:9200/_ml/anomaly_detectors/mon_job/_stats"
Statistiques d'un job ML
curl -X GET "localhost:9200/_ml/datafeeds"
Liste les datafeeds ML
curl -X GET "localhost:9200/_ml/filters"
Liste les filtres ML
curl -X GET "localhost:9200/_ml/calendars"
Liste les calendriers ML
curl -X GET "localhost:9200/_watcher/watch"
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"}}}}'
Crée une watch
curl -X POST "localhost:9200/_watcher/watch/mon_watch/_execute"
Exécute manuellement une watch
curl -X DELETE "localhost:9200/_watcher/watch/mon_watch"
Supprime une watch
curl -X GET "localhost:9200/_watcher/stats"
Statistiques Watcher
curl -X POST "localhost:9200/_watcher/_start"
Démarre Watcher
curl -X POST "localhost:9200/_watcher/_stop"
Arrête Watcher
curl -X GET "localhost:9200/_graph/explore" -H 'Content-Type: application/json' -d'{"index": "logs", "query": {"match": {"message": "error"}}}'
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"}'
Requête SQL
?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"}'
Traduit SQL en requête Elasticsearch
curl -X GET "localhost:9200/_sql/stats"
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]"}'
Requête EQL (Event Query Language)
curl -X GET "localhost:9200/_eql/stats"
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"}}}'
Crée un job de rollup
curl -X POST "localhost:9200/_rollup/job/mon_rollup/_start"
Démarre un job de rollup
curl -X GET "localhost:9200/_rollup/job/mon_rollup"
Informations sur un job de rollup
curl -X GET "localhost:9200/_rollup/data/mon_rollup"
Récupère les données rollup
curl -X GET "localhost:9200/_searchable_snapshots/stats"
Statistiques des snapshots consultables
?pretty
curl -X POST "localhost:9200/_migration/deprecations"
Vérifie les API dépréciées utilisées
?index
curl -X POST "localhost:9200/_migration/upgrade/monindex"
Met à niveau un index vers la version actuelle
curl -X POST "localhost:9200/_migration/post_feature_upgrade"
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"}'
Analyse un texte avec un analyseur
curl -X GET "localhost:9200/_analyze" -H 'Content-Type: application/json' -d'{"field": "name", "text": "John Doe"}'
Analyse avec l'analyseur d'un champ
curl -X POST "localhost:9200/monindex/_termvectors/1?fields=description"
Récupère les vecteurs de termes d'un document
?fields&term_statistics&field_statistics
curl -X POST "localhost:9200/_mtermvectors" -H 'Content-Type: application/json' -d'{"docs": [{"_index": "monindex", "_id": "1", "fields": ["description"]}]}'
Multi termvectors
curl -X GET "localhost:9200/_field_caps?fields=name,age"
Capacités des champs à travers les index
?fields
curl -X GET "localhost:9200/_nodes/reload_secure_settings"
Recharge les paramètres sécurisés (keystore)
curl -X GET "localhost:9200/_ssl/certificates"
Informations sur les certificats SSL
?pretty
curl -X GET "localhost:9200/_autoscaling/policy"
Liste les politiques d'autoscaling
curl -X GET "localhost:9200/_autoscaling/capacity"
Capacité actuelle d'autoscaling
curl -X GET "localhost:9200/_logs/index.mappings"
Affiche le mapping des logs Elasticsearch