# Sort by country with one specific country first

**URL:** <https://discuss.elastic.co/t/sort-by-country-with-one-specific-country-first/245100>\
**Category:** Elasticsearch\
**Created:** [August 15, 2020, 3:32pm UTC](https://discuss.elastic.co/t/sort-by-country-with-one-specific-country-first/245100 "2020-08-15T15:32:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![steff7](https://avatars.discourse-cdn.com/v4/letter/s/cdc98d/32.png) [@steff7](https://discuss.elastic.co/u/steff7)\
**Post date:** [August 15, 2020, 3:32pm UTC](https://discuss.elastic.co/t/sort-by-country-with-one-specific-country-first/245100/1 "2020-08-15T15:32:02Z")

</div>

Hello,  
I am new to Elastic and I am trying to get a list of products. My bool query works in general but now i want to solve the following sorting problem.

The multilanguage website shows products of different countries.  
The list should first show the products of the country of the user and after that the rest of the products, ordered by country. Is that possible to realize without two separated queries?

In my query the sorting looks like this at the moment (PHP)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/d/4de6938cdc0df53af287a5e00015d20d2120aa71.png)

---

<div class="post-metadata">

**Author:** ![steff7](https://avatars.discourse-cdn.com/v4/letter/s/cdc98d/32.png) [@steff7](https://discuss.elastic.co/u/steff7)\
**Post date:** [August 18, 2020, 4:45pm UTC](https://discuss.elastic.co/t/sort-by-country-with-one-specific-country-first/245100/2 "2020-08-18T16:45:50Z")

</div>

Can somebody please help me or just give me a hint if it is possible or not?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 18, 2020, 9:20pm UTC](https://discuss.elastic.co/t/sort-by-country-with-one-specific-country-first/245100/3 "2020-08-18T21:20:48Z")

</div>

[https://www.elastic.co/guide/en/elasticsearch/reference/7.9/query-dsl-pinned-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.9/query-dsl-pinned-query.html) might do what you want.

Otherwise you may be able to craft a query with a boost on the user's country value.

---

<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:** [September 15, 2020, 9:20pm UTC](https://discuss.elastic.co/t/sort-by-country-with-one-specific-country-first/245100/4 "2020-09-15T21:20:50Z")

</div>

Closed on September 15, 2020, 9:20pm UTC

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