Playing with elasticsearch indices

List all indices

curl -X GET "localhost:9200/_cat/indices?v"

List indices matching a pattern


curl -XGET localhost:9200/_cat/indices/syslog*?v

health status index             uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   syslog-2019.03.17 YOl_8xiaRxSWbOTzIfM6UQ   5   1    5503949            0    940.9mb        940.9mb
yellow open   syslog-2019.03.15 LRj4X2zQSa23cDAua1Glpw   5   1    4595158            0    771.6mb        771.6mb
yellow open   syslog-2019.03.14 a_ii5ZknRrW9UodC3t_p5A   5   1    1546130            0    219.6mb        219.6mb
yellow open   syslog-2019.03.16 2crctt3aSxuj0bK82IdmkA   5   1    5454493            0    817.7mb        817.7mb
yellow open   syslog-2019.03.18 ZLQXHFgzTdK124Zp0iMQNw   5   1     726255            0    182.4mb        182.4mb

Delete an index


curl -X DELETE "localhost:9200/syslog-2019.03.13"

{"acknowledged":true}

Fetch available fields in an index


curl -X GET "localhost:9200/syslog-2019.03.17/"
{
   "syslog-2019.03.17":{
      "aliases":{

      },
      "mappings":{
         "fluentd":{
            "properties":{
               "@timestamp":{
                  "type":"date"
               },
               "host":{
                  "type":"text",
                  "fields":{
                     "keyword":{
                        "type":"keyword",
                        "ignore_above":256
                     }
                  }
               },
               "ident":{
                  "type":"text",
                  "fields":{
                     "keyword":{
                        "type":"keyword",
                        "ignore_above":256
                     }
                  }
               },
               "message":{
                  "type":"text",
                  "fields":{
                     "keyword":{
                        "type":"keyword",
                        "ignore_above":256
                     }
                  }
               },
               "pid":{
                  "type":"text",
                  "fields":{
                     "keyword":{
                        "type":"keyword",
                        "ignore_above":256
                     }
                  }
               },
               "tag":{
                  "type":"text",
                  "fields":{
                     "keyword":{
                        "type":"keyword",
                        "ignore_above":256
                     }
                  }
               }
            }
         }
      },
      "settings":{
         "index":{
            "creation_date":"1552780803151",
            "number_of_shards":"5",
            "number_of_replicas":"1",
            "uuid":"YOl_8xiaRxSWbOTzIfM6UQ",
            "version":{
               "created":"6060199"
            },
            "provided_name":"syslog-2019.03.17"
         }
      }
   }
}

Search something within an index


curl -X GET "localhost:9200/<index name>/_search?q=<query>"