1011 0 0 0
Last Updated : 2025-04-28 21:29:05
Im my case, I wanted to sort results of the general search based on the most recent parliament number, then the most recent session number. This is fine as far as both fields are already mapped for all indices. But when the field is missing, such as in my case the parliament number, then you shall direct the elasticsearch to know how he will be doing with these missing fields in other indices, So here is how to tell it :
"sort" : [
{
"parlNumberAsNumber" :
{
"order" : "desc",
"missing" : "_last", //This will tell it that this field when missing , show the results at the end
"unmapped_type" : "integer" //This is the main field here, that will direct the elasticsearch to consider if the field is there and mapped as integer or any other this
}
} ,
{
"session" :
{
"order" : "desc"
}
}
],