I'm looking for a way to save a dotted version as string (e.g "1.2.23") in elastic and then use range query on this field. e.g
{
"query": {
"range": {
"version": {"gte": "1.2.3", "lt": "1.3"}
}
}
}
I have only 3 components (major, minor, build). I need to be able to determine that
I thought about the following approaches:
Any other ideas or recommendations?
If you have some latitude in your indexing code to massage those semantic versions into something else, I would suggest to transform each version into a unique integer and then it's very easy to compare those numbers with a single range
query.
The algorithm is simple:
1.2.34
=> 1
, 2
, 34
1
=> 1000000
2
=> 2000
1000000 + 2000 + 34
=> 1002034
range
queriesIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With