# Elasticsearch query and sorting by parameters Ask

**URL:** <https://discuss.elastic.co/t/elasticsearch-query-and-sorting-by-parameters-ask/134252>\
**Category:** Elasticsearch\
**Created:** [June 1, 2018, 3:46pm UTC](https://discuss.elastic.co/t/elasticsearch-query-and-sorting-by-parameters-ask/134252 "2018-06-01T15:46:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amiralii](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amiralii/32/31852_2.png) [@amiralii](https://discuss.elastic.co/u/amiralii)\
**Post date:** [June 1, 2018, 3:46pm UTC](https://discuss.elastic.co/t/elasticsearch-query-and-sorting-by-parameters-ask/134252/1 "2018-06-01T15:46:44Z")

</div>

How can I query and sort text by below parameter in elasticsearch

1 - search query be exact in the first part of results

2 - search query be exact in another part of the result

3 - results contain all words of the search query

For example :

I searching `i love dogs`

Results respectively must be :

```
      1- I love dogs

      2 - i love dogs and birds

      3 - birds good but i love dogs and horses 

      4 - Horses and i love dogs

      5 - I love horses and dogs

      6 - good dogs and i love horses
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 1, 2018, 6:45pm UTC](https://discuss.elastic.co/t/elasticsearch-query-and-sorting-by-parameters-ask/134252/2 "2018-06-01T18:45:43Z")

</div>

Have a look at this script:

> <https://gist.github.com/dadoonet/5179ee72ecbf08f12f53d4bda1b76bab>

This might give you some ideas.

---

<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:** [June 29, 2018, 6:45pm UTC](https://discuss.elastic.co/t/elasticsearch-query-and-sorting-by-parameters-ask/134252/3 "2018-06-29T18:45:45Z")

</div>

Closed on June 29, 2018, 6:45pm UTC

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