Skip to content

Elastic Curl Commands

ElasticSearch Commands Cheat Sheet – BMC Software | Blogs

ELASTIC_USER=elastic
ELASTIC_USER=admin
ELASTIC_PASS=admin
ELASTIC_NODE=http://localhost:9200
curl -XGET  -iL -u $ELASTIC_USER:$ELASTIC_PASS $ELASTIC_NODE/_cluster/health?pretty --insecure
curl -XGET  -iL -u $ELASTIC_USER:$ELASTIC_PASS $ELASTIC_NODE/_cat/indices/*?v&s=index --insecure 
curl -XPUT  -iL -u $ELASTIC_USER:$ELASTIC_PASS "$ELASTIC_NODE/movies/movie/1" -d''
curl -XPOST -iL -u $ELASTIC_USER:$ELASTIC_PASS "$ELASTIC_NODE/test/_doc/1" -d @lane.json
curl -v -s -XPUT -iL -u $ELASTIC_USER:$ELASTIC_PASS "$ELASTIC_NODE/${INDEX_NAME}?pretty"
 curl -XDELETE http://<node-ip|hostname>:9200/<index-name>

Change Password

User Management

PUT _plugins/_security/api/account
{
    "current_password" : "old-password",
    "password" : "new-password"
}
ELASTIC_USER=admin
ELASTIC_PASS=admin
ELASTIC_NODE=http://localhost:9200
curl --header "Content-Type: application/json" \
  -u $ELASTIC_USER:$ELASTIC_PASS \
  --request PUT \
  --data '{"current_password" : "admin","password" : "admin2"}' \
  $ELASTIC_NODE/_plugins/_security/api/account --insecure

curl --header "Content-Type: application/json" \
  -u $ELASTIC_USER:$ELASTIC_PASS \
  --request PUT \
  --data '{"password": "kirkpass"}' \
  https://localhost:9200/_plugins/_security/api/internalusers/spock --insecure