# Skip\_duplicates keeps the lowest-scored document

**URL:** https://discuss.elastic.co/t/skip-duplicates-keeps-the-lowest-scored-document/157914
**Category:** Elasticsearch
**Created:** [November 22, 2018, 4:30pm UTC](https://discuss.elastic.co/t/skip-duplicates-keeps-the-lowest-scored-document/157914 "2018-11-22T16:30:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![samogon](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@samogon](https://discuss.elastic.co/u/samogon)
#### Post date: [November 22, 2018, 4:30pm UTC](https://discuss.elastic.co/t/skip-duplicates-keeps-the-lowest-scored-document/157914/1 "2018-11-22T16:30:14Z")

</div>

Hi,

I'm using completion suggester with contexts. Elasticsearch version 6.5.1 from docker hub (official).

Here's the mapping:

```
PUT /listing_address
{
  "mappings": {
    "listing": {
      "properties": {
        "suggest": {
          "type": "completion",
          "analyzer": "standard",
          "contexts": [
          	{
          		"name": "status_and_rental",
          		"type": "category"
          	}
          ]
        }
      }
    }
  }
}

```

I have a bunch of documents in the `listing_address` index:

```
PUT /listing_address/listing/123123123
{
"suggest": {
    "contexts": {
        "status_and_rental": "U"
    },
    "input": [
        "502-30 Church St, Toronto, ON, M5E1S7",
        "30 Church St Toronto ON M5E1S7"
    ],
    "weight": 662
}
}

PUT /listing_address/listing/123123124
{
"suggest": {
    "contexts": {
        "status_and_rental": "UR"
    },
    "input": [
        "502-30 Church St, Toronto, ON, M5E1S7",
        "30 Church St Toronto ON M5E1S7"
    ],
    "weight": 710
}
}

PUT /listing_address/listing/123123125
{
"suggest": {
    "contexts": {
        "status_and_rental": "U"
    },
    "input": [
        "502-30 Church St, Toronto, ON, M5E1S7",
        "30 Church St Toronto ON M5E1S7"
    ],
    "weight": 1228
}
}

```

"status\_and\_rental" context varies from document to document with possible values of "U" or "UR". Weight varies between 662 and 1228.

Here's my search query:

```
POST /listing_address/_search?pretty
{
  "suggest": {
	 "address-suggest": {
    	"prefix": "502-30 church",
		"completion": {
			"field": "suggest",
			"size": 99,
			"skip_duplicates": true,
			"contexts": {
				"status_and_rental": ["UR", "U"]
			}
		}
      }
  }
}

```

The query returns one document with the weight of 662. But there are other documents with higher weight. I would expect the document with the highest weight to be returned. What am I doing wrong?

---

<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: [December 20, 2018, 4:31pm UTC](https://discuss.elastic.co/t/skip-duplicates-keeps-the-lowest-scored-document/157914/2 "2018-12-20T16:31:36Z")

</div>

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