# How to give higher score to exact searches than phonetic ones in Elasticsearch?

**URL:** https://discuss.elastic.co/t/how-to-give-higher-score-to-exact-searches-than-phonetic-ones-in-elasticsearch/218197
**Category:** Elasticsearch
**Created:** [February 6, 2020, 2:38pm UTC](https://discuss.elastic.co/t/how-to-give-higher-score-to-exact-searches-than-phonetic-ones-in-elasticsearch/218197 "2020-02-06T14:38:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![abhijith\_chandran](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhijith_chandran/32/60470_2.png) [@abhijith\_chandran](https://discuss.elastic.co/u/abhijith_chandran)
#### Post date: [February 6, 2020, 2:38pm UTC](https://discuss.elastic.co/t/how-to-give-higher-score-to-exact-searches-than-phonetic-ones-in-elasticsearch/218197/1 "2020-02-06T14:38:11Z")

</div>

I am currenty using Elasticsearch's phonetic analyzer. I want the query to give higher score to exact matches then phonetic ones. Here is the query I am using:

```auto
{
    "query": {
        "multi_match" : {
            "query" : "Abhijeet",
            "fields" : ["content", "title"]

        }
    },         
     "size": 10,
     "_source": ["title", "bench", "court", "id_"],
     "highlight": {
        "fields" : {
            "title" : {},
            "content":{}
        }
    }

}

```

When I search for `Abhijeet` , the top queries are `Abhijit` and only later does `Abhijeet` come. I want the exact matches to appear first, all the time and then the phonetic ones. Can this be done?

---

<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: [February 6, 2020, 2:47pm UTC](https://discuss.elastic.co/t/how-to-give-higher-score-to-exact-searches-than-phonetic-ones-in-elasticsearch/218197/2 "2020-02-06T14:47:42Z")

</div>

You don't have to settle on one indexing strategy or querying strategy:

- Index your field multiple ways in the mapping using [multi-fields](https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html)
- Query your data using a `bool` query containing an array of `should` clauses - some targeting the phonetic field, others the field used for exact-matching. The `bool` query will take care of scoring docs that match both clauses highest.

---

<div class="post-metadata">

### Author: ![abhijith\_chandran](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhijith_chandran/32/60470_2.png) [@abhijith\_chandran](https://discuss.elastic.co/u/abhijith_chandran)
#### Post date: [February 6, 2020, 2:56pm UTC](https://discuss.elastic.co/t/how-to-give-higher-score-to-exact-searches-than-phonetic-ones-in-elasticsearch/218197/3 "2020-02-06T14:56:47Z")

</div>

H @Mark_Harwood !  
So for example I have the `content` field that contans the phonetic analyzer. Now when I search in the field I want the exact matches to come first, then the phonetic matches. I am just beginning out and if it isn't much trouble to you, a code example showing this will be really helpful.

---

<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 5, 2020, 2:56pm UTC](https://discuss.elastic.co/t/how-to-give-higher-score-to-exact-searches-than-phonetic-ones-in-elasticsearch/218197/4 "2020-03-05T14:56:51Z")

</div>

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