Aggregations from REST-call

I have constructed a search in Kibana Dev-tool, that gives me the respond I'm looking for. In there I have an aggregation:

GET /monitor/_search
{
  "query": {
    "bool": {
      "must": [
        { "match": {"_type": "ActivitySummary"} }          ],
      "should": [
        { "match": {"activityName": "Formulär"} },
        { "match": {"activityName": "Beslut"} }
      ],
    "minimum_should_match" : 1
    }
  },
  "sort":  {"taskStartTime": { "order": "asc" }},
  "_source": [ "taskStartTime", "taskCompletedTime", "activityName", "taskInstanceId", "processInstanceId"],
  "size": 0,
  "aggs": {
    "days": {
      "date_histogram": {
        "field": "taskStartTime",
        "interval": "day"
      }
    }
  }
}

Is there any way to call for that aggregation in a REST-request in the http://localhost:9200/monitor/_search?q=...-format?
How do I do that?

Yep! DevTools actually has an option to do that automatically for you. If you click the little wrench icon at the top-right of your query, a drop-down will have the option "Copy as Curl":

Which gives you:

curl -XGET "http://localhost:9200/monitor/_search" -H 'Content-Type: application/json' -d'
{
  "query": {
    "bool": {
      "must": [
        { "match": {"_type": "ActivitySummary"} }          ],
      "should": [
        { "match": {"activityName": "Formulär"} },
        { "match": {"activityName": "Beslut"} }
      ],
    "minimum_should_match" : 1
    }
  },
  "sort":  {"taskStartTime": { "order": "asc" }},
  "_source": [ "taskStartTime", "taskCompletedTime", "activityName", "taskInstanceId", "processInstanceId"],
  "size": 0,
  "aggs": {
    "days": {
      "date_histogram": {
        "field": "taskStartTime",
        "interval": "day"
      }
    }
  }
}'

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