# Problem with Completion suggester

**URL:** <https://discuss.elastic.co/t/problem-with-completion-suggester/181695>\
**Category:** Elasticsearch\
**Created:** [May 18, 2019, 6:23pm UTC](https://discuss.elastic.co/t/problem-with-completion-suggester/181695 "2019-05-18T18:23:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dojutsu-user](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dojutsu-user/32/46428_2.png) [@dojutsu-user](https://discuss.elastic.co/u/dojutsu-user)\
**Post date:** [May 18, 2019, 6:23pm UTC](https://discuss.elastic.co/t/problem-with-completion-suggester/181695/1 "2019-05-18T18:23:19Z")

</div>

(Using ES 6.7)  
I have an index and want to support search-as-you-type feature. For that, I want to try completion suggester but I'm having trouble in reindexing to change the mappings old index.

Here's the old index mappings

```
{
    "old-index": {
        "mappings": {
            "doc": {
                "properties": {
                    "content": {
                        "type": "text"
                    },
                    "project": {
                        "type": "keyword"
                    },
                    "title": {
                        "type": "text"
                    },
                    "version": {
                        "type": "keyword"
                    }
                }
            }
        }
    }
}

```

Here's the new test index mappings

```
PUT test-completion
{
    "mappings": {
        "doc": {
            "properties": {
                "content": {
                    "type": "text",
                    "fields": {
                        "autocomplete": {
                            "type": "completion",
                            "contexts": [
                                {
                                    "name": "project",
                                    "type": "category",
                                    "path": "project"
                                },
                                {
                                    "name": "version",
                                    "type": "category",
                                    "path": "version"
                                }
                            ]
                        }
                    }
                },
                "title": {
                    "type": "text"
                },
                "project": {
                    "type": "keyword"
                },
                "version": {
                    "type": "keyword"
                }
            }
        }
    }
}

```

Here's the reindexing query

```
POST _reindex
{
    "source": {
        "index": "old-index"
    },
    "dest": {
        "index": "test-completion"
    }
}

```

And here's the query which returns no results

```
POST test-completion/_search
{
    "suggest": {
        "autocompletion_suggest": {
            "prefix": "part of documentation",
            "completion": {
                "field": "content.autocomplete",
                "fuzzy": {
                    "fuzziness": "AUTO"
                },
                "contexts": {
                    "project": "xyz-project",
                    "version": "abc-version"
                }
            }
        }
    }
}

```

If the `prefix` is set to `a` or `b`, it returns results outside of context.  
Where I'm 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:** [June 15, 2019, 6:23pm UTC](https://discuss.elastic.co/t/problem-with-completion-suggester/181695/2 "2019-06-15T18:23:23Z")

</div>

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