ES version range comparision is not working as expected semantic version comparison

Hi Folks

I have a version mapping field data type with the property name "softwareVersion" in the Elasticsearch index. I have "softwareVersion" property values like Z100, Z300, 6.7, 7.0(3)I7(3), and 6.8.9

when I search with range query on "softwareVersion" field is giving results as this.

Query:
curl -X GET "localhost:9200/my_index/_search?pretty" -H 'Content-Type: application/json' -d '{"query": {"range": {"softwareVersion": {"lte": "8.0.7" } } } }'

result
the result contains data having version
6.7, 6.8.9

1.My question is why results are not contained with softwareVersion 7.0(3)I7(3) ?

Query:
curl -X GET "localhost:9200/my_index/_search?pretty" -H 'Content-Type: application/json' -d '{"query": {"range": {"softwareVersion": {"lte": "Z500" } } } }'

result
the result contains data having version
Z100, Z300, 6.7, 7.0(3)I7(3), and 6.8.9

but when I hit the below query the results are not as expected which are
Query:
curl -X GET "localhost:9200/my_index/_search?pretty" -H 'Content-Type: application/json' -d '{"query": {"range": {"softwareVersion": {"lte": "Z1000" } } } }'

result
the result contains data having version
Z100, 6.7, 7.0(3)I7(3), and 6.8.9

2.My question is ** why is Z300 not in the result of the above query?**

I am using the Elasticsearch 7.10.2 version and mapping of the "softwareVersion" field as below.

"softwareVersion": {

  •      "type": "version"*
    
  •    }*
    

Thanks & Regards
Krishna Jalla

Elasticsearch 7.10 is EOL and no longer supported. Please upgrade ASAP.

(This is an automated response from your friendly Elastic bot. Please report this post if you have any suggestions or concerns :elasticheart: )

are you suggesting upgrading the version? I think..the above issue is not related to the version. the problem is about version field type comparison.

Thanks
Krishna Jalla

I have not used this field type, but looking at the docs it seems it assumes semantic versioning is used. As far as I can see Z100, Z300, and 7.0(3)I7(3) does not follow the semantic versioning scheme. I am not sure what the expected behaviour is in this case, so will leave it to someone with knowledge of the internals to answer that.

I do not know if any bugs around this feature have been fixed in newer versions, but would always recommend upograding to the latest version.

Hi Christian

can you please suggest to me which version of Elasticsearch should I need to upgrade?

Thanks
Krishna Jalla

If your versions do not follow semantic versioning, which is what is supported by this field type, why would upgrading Elasticsearch solve this?

@Christian_Dahlqvist
thanks for the reply
Yes, the versions do not follow semantic versioning. then the resource in search should not contain those versions, right? I have a lot of invalid semantic versions in DB but can I please know in the above queries what basis/ rule elasticsearch follows in case of invalid semantic versions?

for <= Z500 results are Z100, Z300, 6.7, 7.0(3)I7(3), and 6.8.9
but for <= Z1000 results are Z100, 6.7, 7.0(3)I7(3), and 6.8.9

in Z1000 one why Z300 missed? which is given in Z500 query.

Thanks & Regards
Krishna Jalla

I am not familiar with the code, so will leave it to someone else to answer that.

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