Sort string versions in kibana

Elastic/Kibana version: 7.7(Platinum)
Hi,

In my case I have version fields that look like that "NAME-10.1.0" or "NAME-10.1.1_beta".
So when I sort them in a visualisation(Histogram), they are sorted like this:

NAME-20.19.2
NAME-20.19.3_alpha
NAME-20.19.4
NAME-20.2.0 (This should be way up)
NAME-20.20.0_alpha
NAME-20.20.1_beta

Is there any way to sort string versions correctly?

/Angelos

I'm not sure why you think NAME-20.2.0 should be way up. The names are sorted in a lexicographic order, not semantical.

I made a small JSFiddle to show this is indeed how native Javascript sort method works:
https://jsfiddle.net/#run&togetherjs=prMnyzRM0S

Hi,

Thank you for your response.
So, we have to change the way we index this field.

/Angelos

What is your use-case? Would you simply like to see this sorted in a descending order?

I want semantic version sorting(ascending), so it will look like that:

NAME-20.2.0
NAME-20.2.1
NAME-20.2.2
NAME-20.2.3
NAME-20.2.4
NAME-20.3.0
NAME-20.3.1
.
.
.
NAME-20.19.2
NAME-20.19.3_alpha
NAME-20.19.4
NAME-20.20.0_alpha
NAME-20.20.1_beta

/Angelos

Yes, for that the best would be to store the versions in a separate field in ES.

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