I posted this question to find out if there is a better way to return
years in a elasticsearch database, Without using aggregations.
the kind of field is this:
{"type" : "date", "format": "dd-MM-yyyy HH:mm:ss"}
Note: I already can return the values using aggregations and date_histogram. This way:
GET _search
{ "size": 0,
"aggs": {
"group_by_doenca": {
"date_histogram": {
"field": "data",
"interval" : "year",
"format": "yyyy"
}
}
}
}
And is returning me correctly this:
"hits": {
"total": 100000000,
"max_score": 0,
"hits": []
},
"aggregations": {
"group_by_date": {
"buckets": [
{
"key_as_string": "1995",
"key": 788918400000,
"doc_count": 4547094
},
{
"key_as_string": "1996",
"key": 820454400000,
"doc_count": 4543451
},
{
"key_as_string": "1997",
"key": 852076800000,
"doc_count": 4547131
},
....
As you can see, this base has 100kk of "lines" and the return time of this search of is about 5 seconds.
I need only the different years, do not need the doc_count of these years.
So I wonder if there is how to modify this research, to be faster, and only return me the information I need?
Thank you so much