Sorting on nested field with conditon


(Julien Sebrien) #1

Hello,

I have the following document:

{
"mappings" : {
"doc":{
"properties":{
...
"notations": {
"type": "nested"
}
}
}
}
}

In "notations", I have elements like:

{
"key":"default"
"grade":5
},

{
"key":"custom"
"grade":8
}

Is it possible to sort with field notations.grade with the following condition:

if (exist notation.key=="custom") take the corresponding notation.grade
else if (exist notation.key=="default") take the corresponding notation.grade

?

I saw the documentation describing nested sorting examples here:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html

but it does not tell if we can add an "else if" condition.

Is there another way to implement that behavior?

Regards,

Julien


(system) #2

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