# MLT query to change score only

**URL:** https://discuss.elastic.co/t/mlt-query-to-change-score-only/70546
**Category:** Elasticsearch
**Created:** [January 4, 2017, 12:10pm UTC](https://discuss.elastic.co/t/mlt-query-to-change-score-only/70546 "2017-01-04T12:10:37Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![enp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enp/32/3825_2.png) [@enp](https://discuss.elastic.co/u/enp)
#### Post date: [January 4, 2017, 12:10pm UTC](https://discuss.elastic.co/t/mlt-query-to-change-score-only/70546/1 "2017-01-04T12:10:37Z")

</div>

Hi,

Is it possible to write MLT query to ES which will not filter results, but will change score only, so unmatched documents will be at the end of result set?

---

<div class="post-metadata">

### Author: ![enp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enp/32/3825_2.png) [@enp](https://discuss.elastic.co/u/enp)
#### Post date: [January 4, 2017, 12:37pm UTC](https://discuss.elastic.co/t/mlt-query-to-change-score-only/70546/2 "2017-01-04T12:37:52Z")

</div>

I tried to do this with simple term query first:

```
POST locations/_search?size=100
{
  "query": {
    "bool": {
      "should": {
        "term": {
          "country_code" : "mz"
        }
      },
      "minimum_should_match": 0
    }
  }
}

```

I used "should" and "minimum\_should\_match" due to description from [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html:](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html:)

> In a boolean query with no must or filter clauses, one or more should clauses must match a document. The minimum number of should clauses to match can be set using the minimum\_should\_match parameter.

So, I guessed to see documents with "country\_code" : "mz" and all other documents next, but I see only 18 documents with "country\_code" : "mz" and not 100 documents as described by size=100.

Where is my error and how to apply any query to score only without filtering?

---

<div class="post-metadata">

### Author: ![enp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enp/32/3825_2.png) [@enp](https://discuss.elastic.co/u/enp)
#### Post date: [January 4, 2017, 12:49pm UTC](https://discuss.elastic.co/t/mlt-query-to-change-score-only/70546/3 "2017-01-04T12:49:31Z")

</div>

Looks like "minimum\_should\_match" can't be less than 1, but I can add "match\_all":

```
POST locations/_search?size=100
{
  "query": {
    "bool": {
      "should": [
        {
          "match_all": {}
        },
        {
          "term": {
            "country_code": "mg"
          }
        }
      ],
      "minimum_should_match": 1
    }
  }
}
```

---

<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: [February 1, 2017, 12:49pm UTC](https://discuss.elastic.co/t/mlt-query-to-change-score-only/70546/4 "2017-02-01T12:49:36Z")

</div>

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