Version string comparison

I have some documents with one attribute version like “1.0”,“1.0.1”,“1.1”,“1.1.0”,“1.2”.

I am able get the documents where version is greater than 1.1 but when version is 1.10 then the query is considering 1.10 as 1.1 and bringing unwanted records.

Any solution for this issue ?

You could use the “SPLIT” string function to break down the version numbers into component parts, and “TONUMBER” to enable comparison by value. E.g. if your version field is called “version”:

select * from my_bucket where TONUMBER(SPLIT(version,"."))[0] >= 1 and TONUMBER(SPLIT(version,"."))[1] >= 10;