Getting the list of years of type


(Juan Diego Calle) #1

I have a type called vehicle_type that has a field called built_year, I want to get a list of years of my vehicles.
I got a list of years with an aggregate (bucket)

{
     "aggs": {
       "years": {
         "terms": {
           "field": "built_year",
           "size": 20
         }
       }
     }
}

Is it possible to get a list of all the years in order (DESC or ASC).


(Mark Walkom) #2

You're close! This is what you want, just use order as well and increase your size.


(system) #3