Ordering the buckets alphabetically by their terms in an ascending manner

I have upgraded Elasticsearch recently from 2.4.1 to 5.1.2

I'm using the query,

GET /question/question_name/_search
{
"size": 0,
"aggs": {
"agg": {
"terms": {
"field": "question_name.raw",
"order": {
"_term": "asc"
},
"size": 10000
}
}
}
}

Response :

{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2122,
"max_score": 0,
"hits":
},
"aggregations": {
"agg": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets":
}
}
}

It's returning buckets as empty .

Anyone please help me on this.

Hey,

can you check your mapping, if you have a field called question_name.raw?

--Alex

I checked the mapping and i found this:

GET /question_search_navigation_data/question_name_details/_mapping

"question_name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}

Same query worked fine before upgrading the Elasticsearch

Hey,

you have not ported over the mappings. You need to use question_name.keyword to make it work.

--Alex

1 Like

Thank you very much. It worked for me.

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