# Getting the list of years of type

**URL:** <https://discuss.elastic.co/t/getting-the-list-of-years-of-type/35103>\
**Category:** Elasticsearch\
**Created:** [November 20, 2015, 12:43am UTC](https://discuss.elastic.co/t/getting-the-list-of-years-of-type/35103 "2015-11-20T00:43:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juan\_Diego\_Calle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/juan_diego_calle/32/6037_2.png) [@Juan\_Diego\_Calle](https://discuss.elastic.co/u/Juan_Diego_Calle)\
**Post date:** [November 20, 2015, 12:43am UTC](https://discuss.elastic.co/t/getting-the-list-of-years-of-type/35103/1 "2015-11-20T00:43:16Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 20, 2015, 4:25am UTC](https://discuss.elastic.co/t/getting-the-list-of-years-of-type/35103/2 "2015-11-20T04:25:07Z")

</div>

You're close! This is what you want, just use [`order`](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-order) as well and increase your `size`.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:37pm UTC](https://discuss.elastic.co/t/getting-the-list-of-years-of-type/35103/3 "2017-07-05T23:37:04Z")

</div>

Closed on July 5, 2017, 11:37pm UTC


