HC LW
HC LW

Reputation: 197

Elastic Search (COUNT*) query

This seems relatively simple but I'm new to Query DSL. Could yall please help me turn this into code?...

Assuming, I have a 'flight data' set where the dates 1-1-2000 and 1-10-2000 hold many flights (flightId, flightDest, etc.), I want to count* flights between those two dates at intervals of one day.

Thanks

Upvotes: 1

Views: 1638

Answers (1)

Saeed Nasehi
Saeed Nasehi

Reputation: 1000

The requested query would be something like below:

GET flight_data_set/_search
{
  "size": 0,
  "query": {
    "range": {
      "flight_date": {
        "gte": "2000-01-01",
        "lte": "2000-10-01"
      }
    }
  }, 
  "aggs": {
    "flight_count_per_day": {
      "date_histogram": {
        "field": "flight_date",
        "interval": "day"
      }
    }
  }
}

Upvotes: 1

Related Questions