Rest API for last 30 days data from elasticsearch

Hi All,

I am trying to export data from elasticsearch using rest api

below is an example which got succeeded, but this will give complete data present in index

URL : http://dashboard.iff.com:9200/inctable/_search/

How do i pull data for last 30 days using the rest API.

Any advice please.

Thanks
Gautham

Use a filter with a date range and you should be good to go - Range query | Elasticsearch Reference [7.10] | Elastic

@warkolm I'm able to get this in dev tools, but how do i convert it as a rest URL?

Thanks
Gautham

in dev tools, there is an option called "Copy as curl" (available after clicking on wrench button beside the execute button), where you can get the rest URL. It will give you something like this:

curl -XGET "http://localhost:9200/test_index/_search" -H 'Content-Type: application/json' -d'
{
  "size": 0,
  "aggs": {
    "stats_agg": {
      "stats": {
        "field": "time"
      }
    }
  }
}'

Curl is fine, but i need it as a direct rest URL, like the one i mentioned below,

http://dashboard.iff.com:9200/inctable/_search/

can we add the aggs directly into an URL

Thanks
Gautham

AFAIK...that can not be done. If you find something, please post it here.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.