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

**URL:** <https://discuss.elastic.co/t/search-with-multiple-keyword-must-should-and-sort-on-other-column/141159>\
**Category:** Elasticsearch\
**Created:** [July 23, 2018, 11:40am UTC](https://discuss.elastic.co/t/search-with-multiple-keyword-must-should-and-sort-on-other-column/141159 "2018-07-23T11:40:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BDuck](https://avatars.discourse-cdn.com/v4/letter/b/5e9695/32.png) [@BDuck](https://discuss.elastic.co/u/BDuck)\
**Post date:** [July 23, 2018, 11:40am UTC](https://discuss.elastic.co/t/search-with-multiple-keyword-must-should-and-sort-on-other-column/141159/1 "2018-07-23T11:40:42Z")

</div>

First of all say hello to staffs and users here 🙂  
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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 20, 2018, 11:40am UTC](https://discuss.elastic.co/t/search-with-multiple-keyword-must-should-and-sort-on-other-column/141159/2 "2018-08-20T11:40:46Z")

</div>

Closed on August 20, 2018, 11:40am UTC

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