# Phrase Suggester Returns Suggestions from Deleted Documents as of 7.0.0

**URL:** <https://discuss.elastic.co/t/phrase-suggester-returns-suggestions-from-deleted-documents-as-of-7-0-0/265068>\
**Category:** Elasticsearch\
**Created:** [February 22, 2021, 1:39pm UTC](https://discuss.elastic.co/t/phrase-suggester-returns-suggestions-from-deleted-documents-as-of-7-0-0/265068 "2021-02-22T13:39:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bencody](https://avatars.discourse-cdn.com/v4/letter/b/c68b51/32.png) [@bencody](https://discuss.elastic.co/u/bencody)\
**Post date:** [February 22, 2021, 1:39pm UTC](https://discuss.elastic.co/t/phrase-suggester-returns-suggestions-from-deleted-documents-as-of-7-0-0/265068/1 "2021-02-22T13:39:20Z")

</div>

**Issue**

As of Elasticsearch 7.0.0, the Phrase Suggester returns suggestions of deleted documents.

I assume this is a bug. However, the documentation on [Suggesters | Elasticsearch Reference [7.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html) does not state how deleted documents are handled by suggesters in general. The documentation of the Completion Suggester specifically mentions that it does not return results of deleted documents, but it is unclear if this implies that the other suggesters do make use of deleted documents.

**Scenario**

- Given an index with a text property
- When document 1 with property "coarse" is indexed
- And all documents are deleted
- And document 2 with property "course" is indexed
- And phrase suggestions for value "corse" are requested
- Then only the suggestion "course" (from document 2) should be returned

Here are the Kibana dev tools requests:

```auto
PUT test_index
{
  "mappings": {
    "properties": {
      "some_field": {
        "type": "text"
      }
    }
  }
}

PUT test_index/_doc/1
{"some_field":"Coarse"}

POST /test_index/_delete_by_query
{"query":{"match_all":{}}}

PUT test_index/_doc/2
{"some_field":"Course"}

GET /test_index/_search
{
  "size": 0,
  "suggest": {
    "suggestions": {
      "text": "corse",
      "phrase": {
        "field": "some_field"
      }
    }
  }
}

```

**Results**

In version 6.8.14 this scenario behaves as I expected. As of 7.0.0 this scenario fails because 2 suggestions are returned: "coarse" and "course". I do not expect "coarse" from document 1 to be returned as a suggestion because that document was deleted.

I did not find anything in the release notes or breaking changes of Elasticsearch 7.0.0 which could relate to this change of behavior, so I assume that this is a bug.

Could I please get feedback on this from an Elasticsearch developer? Can you confirm that this is a bug, so that I can post a bug report on the Elasticsearch Github?

---

<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 22, 2021, 1:39pm UTC](https://discuss.elastic.co/t/phrase-suggester-returns-suggestions-from-deleted-documents-as-of-7-0-0/265068/2 "2021-03-22T13:39:42Z")

</div>

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