Elasticsearch ordering by field value which is not in the filter
You would need a custom sort using script to achieve what you want. I’ve just made use of generic match_all query for my query, you can probably go ahead and add your query logic there, but the solution that you are looking for is in the sort section of the below query. Make sure that status is a keyword type Custom Sorting Based on Values …