elasticsearch curl query examples

A quick way to get results from elasticsearch, test your queries and make sure your data is being indexed correctly is to fire off some queries from the command line. Using curl, you can get this going quickly.

View all your elasticsearch indices:
curl -XGET http://localhost:9200/_cat/indices?v

A quick search across all indices:
curl -XGET http://localhost:9200/_search/?q=foo
(search term is foo)

Limit you search to a specific index:
curl -XGET http://localhost:9200/access-logs/_search/?q=foo
(access-logs is the index name to query, foo is the search term)

Limit your search to a specific fieldname:
curl -XGET http://localhost:9200/access-logs/_search/?q=referer:google.com
This example would show you all referral traffic from google when analyzing your access-logs.

Add a Comment

Your email address will not be published. Required fields are marked *