Search with multiple keyword(must + should) and sort on other column?

First of all say hello to staffs and users here :slightly_smiling_face:
I have a small question on es search function

Assume I have few data like:

count:100
text:monkey

count:90
text:king

count:80
text:monkey king

count:70
text:monkey here

count:60
text:king here

count:50
text:monkey king here

I want to search with keyword: monkey king on "text" field; And sort them on "count" desc

I prefer data with both "monkey" and "king" rank the top, then data with "monkey" OR "king". So the result should be:

count:80
text:monkey king

count:50
text:monkey king here

count:100
text:monkey

count:90
text:king

count:70
text:monkey here

count:60
text:king here

Any code I can use in ElasticSearch?

Note: Sure I can search twice to do it But I wonder if I can get my result with 1 search.

Billion thanks in advance.

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