List all indexes on ElasticSearch server?

前端 未结 23 1099
被撕碎了的回忆
被撕碎了的回忆 2020-12-12 09:55

I would like to list all indexes present on an ElasticSearch server. I tried this:

curl -XGET localhost:9200/

but it just gives me this:

23条回答
  •  独厮守ぢ
    2020-12-12 10:22

    I use the _stats/indexes endpoint to get a json blob of data and then filter with jq.

    curl 'localhost:9200/_stats/indexes' | jq '.indices | keys | .[]'
    
    "admin"
    "blazeds"
    "cgi-bin"
    "contacts_v1"
    "flex2gateway"
    "formmail"
    "formmail.pl"
    "gw"
    ...
    

    If you don't want quotes, add a -r flag to jq.

    Yes, the endpoint is indexes and the data key is indices, so they couldn't make up their minds either :)

    I needed this to clean up these garbage indices created by an internal security scan (nessus).

    PS. I highly recommend getting familiar with jq if you're going to interact with ES from the command line.

提交回复
热议问题