Query to get distinct values satisfying two or more conditions

I'm a newbie to elastic search. I was working on some example queries. I have loaded Kibana flight data to the console. Now, I wanted to know the query which will fetch distict flights which land in Italy. Any help would be largely appreciated.

Distinct, based on what criterion?

To find all flights to Italy, you can use a match query on the DestCountry field:

GET kibana_sample_data_flights/_search
  "size": 10,
  "query": {
    "match": {
      "DestCountry": "IT"

The response will tell you the total number of hits. The default behavior of this query is to return just 10 hits, but by increasing the size you can retrieve more. Or, you can combine size with from to paginate through the search results.

Distinct I mean, A flight can go to Italy more than once. The dataset records this as the same flight going to Italy but as a different observation. But then, I wanted to remove those duplicate flight entries. I have tried one piece of code. I'm attaching the query here.

GET /kibana_sample_data_flights/_doc/_search?q=DestCountry : IT

Alright, in the sample dataset all flights only go to a destination once, but yes - your query will tell you the unique number of flights to a destination.

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