0

I'm using this query

POST /stats/_search?filter_path=aggregations.views.value
{
  "aggs": {
    "views": {
      "sum": {
        "field": "viewCount"
      }
    }
  },
  "size": 0,
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "timestamp": {"gte":"now-2d"}
          }
        }
      ]
    }
  }
}

and it gives the result

{
  "aggregations" : {
    "views" : {
      "value" : 49198.0
    }
  }
}

I'm looking to only get "49189.0" or the least amount of info possible, maybe "{value: 49198.0}"

cooldude101
  • 1,215
  • 2
  • 14
  • 29
  • Sorry, not possible with Elasticsearch native options, from my understanding. Are you executing this query in code, or cURL in a shell? There are ways of filtering JSON output in both cases. – IanGabes Jul 03 '20 at 01:10
  • This answer might help: https://stackoverflow.com/a/43774728/4604579 (hint: use jq) – Val Jul 03 '20 at 05:34

0 Answers0