Kibana sorting does not work

Hi,

I am trying to sort the data in Kibana visualization. When i try to sort the data in descending order, it treats 10 is less than 9.

it sorts 10_1_0 less than 9_1_0. In fact it sorts 10_1_0 less than 1_1_0. Please help me.

That is the correct natural sorting order for strings. If you want it to sort correctly as a string, I suspect you will need to make sure strings are the same length using leading zeros. 9_1_0 > 10_1_0, but 10_1_0 > 09_1_0. Another solution would be to store the different parts as an integer with fixed number of digits for minor and patch level, e.g. 90100 and 100100.

Thanks for the reply. As I mentioned above, Kibana doing sorting in visualization. Any possibility to change the query and aggregation below?

Kibana table query looks like below:
{
"query": {
"bool": {
"must": [
{
"query_string": {
"analyze_wildcard": true,
"query": "tag:xxx-1***"
}
},
{
"range": {
"time_stamp": {
"gte": 1362742674401,
"lte": 1520509074401,
"format": "epoch_millis"
}
}
}
],
"must_not": []
}
},
"size": 0,
"_source": {
"excludes": []
},
"aggs": {
"3": {
"terms": {
"field": "_type",
"size": 7,
"order": {
"_term": "desc"
}
}
}

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