# The exact matching result not coming in the top

**URL:** <https://discuss.elastic.co/t/the-exact-matching-result-not-coming-in-the-top/114025>\
**Category:** Elasticsearch\
**Created:** [January 4, 2018, 6:52am UTC](https://discuss.elastic.co/t/the-exact-matching-result-not-coming-in-the-top/114025 "2018-01-04T06:52:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aavrug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aavrug/32/26223_2.png) [@aavrug](https://discuss.elastic.co/u/aavrug)\
**Post date:** [January 4, 2018, 6:52am UTC](https://discuss.elastic.co/t/the-exact-matching-result-not-coming-in-the-top/114025/1 "2018-01-04T06:52:05Z")

</div>

This is the what I am trying with but I am getting `Angular Js` in the last and `Js` in the first. I want to give priority to `Angular Js` then `Angular` and so on. I also implemented the order.

```auto
{
  "sort": [
    {
      "threshold": {
        "order": "desc"
      }
    },
    {
      "last_login": {
        "order": "desc"
      }
    },
    {
      "_score": {
        "order": "desc"
      }
    }
  ],
  "from": 0,
  "track_scores": true,
  "aggs": {},
  "query": {
    "multi_match": {
      "must": [
        {
          "query_string": {
            "use_dis_max": true,
            "fields": [
              "course_name^2",
              "course_type",
              "skills^10"
            ],
            "query": "\"Angular Js\" OR \"Angular\" OR \"Js\""
          }
        }
      ]
    }
  },
  "size": 50
}

```

Is there any way to achieve the result what I am expecting?

---

<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:** [January 4, 2018, 9:29am UTC](https://discuss.elastic.co/t/the-exact-matching-result-not-coming-in-the-top/114025/2 "2018-01-04T09:29:45Z")

</div>

You can combine different types of search like phrase match, match in a bool query.

I wrote a demo gist about this:

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

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [January 4, 2018, 9:43am UTC](https://discuss.elastic.co/t/the-exact-matching-result-not-coming-in-the-top/114025/3 "2018-01-04T09:43:54Z")

</div>

> [@aavrug](#):
>
> Is there any way to achieve the result what I am expecting?

You made relevance score the lowest sort priority. The primary sort order is `threshold` followed by `last_login` date.  
Notice that sites like google make structured data (dates, image sizes) a range filter (e.g. "last week") and not a sort order so that relevance can remain the primary sort order for search results.

---

<div class="post-metadata">

**Author:** ![aavrug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aavrug/32/26223_2.png) [@aavrug](https://discuss.elastic.co/u/aavrug)\
**Post date:** [February 1, 2018, 7:33am UTC](https://discuss.elastic.co/t/the-exact-matching-result-not-coming-in-the-top/114025/4 "2018-02-01T07:33:46Z")

</div>

Thank you got your point.

---

<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:** [March 1, 2018, 7:34am UTC](https://discuss.elastic.co/t/the-exact-matching-result-not-coming-in-the-top/114025/5 "2018-03-01T07:34:24Z")

</div>

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