-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
:Core/Infra/ScriptingScripting abstractions, Painless, and MustacheScripting abstractions, Painless, and MustacheTeam:Core/InfraMeta label for core/infra teamMeta label for core/infra team
Description
When a query sort is defined on a script that returns a VERSION value (https://www.elastic.co/guide/en/elasticsearch/reference/current/version.html), the result is sorted using lexicographic order instead of SemVer
Reproducer
PUT /test
{
"mappings": {
"properties": {
"version": {
"type": "version"
}
}
}
}
POST /_bulk
{"index": {"_index":"test"}}
{"name" : "foo", "version":"1.11.3"}
{"index": {"_index":"test"}}
{"name" : "foo", "version":"1.1.4"}
{"index": {"_index":"test"}}
{"name" : "bar", "version":"1.2"}
POST /test/_search
{
"size": 1000,
"_source": false,
"fields": [
{
"field": "name"
},
{
"field": "version"
}
],
"sort": [
{
"_script": {
"script": {
"lang": "painless",
"source": "doc['version'].value"
},
"type": "string"
}
}
]
}
Also the following does not seem to be an option:
"sort": [
{
"_script": {
"script": {
"lang": "painless",
"source":"$('version', new Version('0'))"
},
"type": "string"
}
}
]
since it tries to cast Version to String (and fails of course)
Labeling as Core/Infra/Scripting, but not sure if it's for Search instead
Metadata
Metadata
Assignees
Labels
:Core/Infra/ScriptingScripting abstractions, Painless, and MustacheScripting abstractions, Painless, and MustacheTeam:Core/InfraMeta label for core/infra teamMeta label for core/infra team