# Increase score for unique words matched

**URL:** <https://discuss.elastic.co/t/increase-score-for-unique-words-matched/219868>\
**Category:** Elasticsearch\
**Created:** [February 18, 2020, 9:33pm UTC](https://discuss.elastic.co/t/increase-score-for-unique-words-matched/219868 "2020-02-18T21:33:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![emarthinsen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emarthinsen/32/23172_2.png) [@emarthinsen](https://discuss.elastic.co/u/emarthinsen)\
**Post date:** [February 18, 2020, 9:33pm UTC](https://discuss.elastic.co/t/increase-score-for-unique-words-matched/219868/1 "2020-02-18T21:33:11Z")

</div>

This one is a little tricky to explain, but here goes.

I have an index with mappings that look like this:

```auto
{
   "mappings":{ 
      "properties":{ 
         "manufacturer":{ 
            "type":"text",
            "analyzer":"standard"
         },
         "product":{ 
            "type":"text",
            "analyzer":"standard"
         }
      }
   }
}

```

And I have some documents that look like this:

```auto
[ 
   { 
      "manufacturer":"foo bar",
      "product":"baz by foo bar"
   },
   { 
      "manufacturer":"foo bar",
      "product:":"something something something qux"
   }
]

```

Lastly, I have a query that looks like this:

```auto
{
   "query":{
      "bool":{
         "should":[
            {
               "match":{
                  "manufacturer":{
                     "query":"foo qux"
                  }
               }
            },
            {
               "match":{
                  "product":{
                     "query":"foo qux"
                  }
               }
            }
         ]
      }
   }
}

```

Running the query, the document with `baz by foo bar` ranks higher than `something something something qux`. I suspect the reason is because `foo` matches both fields in the first document (and closer to the start of each field) where `qux` matches one document, and farther towards the end of the field than `foo` does. I'm guessing a bit there.

What I want to do is have `something something something qux` rank higher, since it matches both tokens in the query (`foo` and `qux`) and not just one of the terms twice.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 19, 2020, 2:51pm UTC](https://discuss.elastic.co/t/increase-score-for-unique-words-matched/219868/2 "2020-02-19T14:51:38Z")

</div>

If you do not understand why some scoring happens, you can always use `"explain": true` in your request to get some enlightenment. See [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-explain](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-explain) and the [explain API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html)

that said I suppose you would need to change a query quite a bit in order to make this work, as foo is matched in both fields, compared to qux. Not really sure if the `multi_match` is of any help here, but you may want to read about the different `type` options available.

---

<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 18, 2020, 2:51pm UTC](https://discuss.elastic.co/t/increase-score-for-unique-words-matched/219868/3 "2020-03-18T14:51:46Z")

</div>

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