# How to filter/limit term or phrase suggester by a specific field?

**URL:** https://discuss.elastic.co/t/how-to-filter-limit-term-or-phrase-suggester-by-a-specific-field/99215
**Category:** Elasticsearch
**Created:** [September 3, 2017, 8:18am UTC](https://discuss.elastic.co/t/how-to-filter-limit-term-or-phrase-suggester-by-a-specific-field/99215 "2017-09-03T08:18:53Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ali.gholami](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ali.gholami/32/21750_2.png) [@ali.gholami](https://discuss.elastic.co/u/ali.gholami)
#### Post date: [September 3, 2017, 8:18am UTC](https://discuss.elastic.co/t/how-to-filter-limit-term-or-phrase-suggester-by-a-specific-field/99215/1 "2017-09-03T08:18:53Z")

</div>

Hi,  
I'm using elastic search 5.3 and to provide did-you-mean functionality, I want to limit the context of term or phrase suggester to _only user's documents_ not all the documents in the index. here's my current \_search query body (which returns suggestion based on all indexed documents):

```
{
    "suggest": {
        "text": "docyment",
        "title_correction: {
            "term": {
                "size": 2,
                "prefix_length": 3,
                "field": "title",
                "analyzer": "standard",
                "min_doc_freq": 1,
            }
        }
    }
}

```

I can see that filtering was part of phrase\_suggester in the past ([check this issue](https://github.com/elastic/elasticsearch/issues/3482)) but it seems that it has been deprecated and replaced by context suggester (only for completion fields though), so it's not suitable for my case.

What I need is to have a filter like: `"filter": {"term": {"user_id": 12345}}` so suggestions will be based on user's documents.

I would appreciate it if anyone could come up with answers to my questions :  
0- why the filter has been deprecated from phrase suggester? only to boost up performance?  
1- if it has been replaced by something else and there's recommended way to do it, so I can solve my issue?

---

<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: [October 1, 2017, 8:22am UTC](https://discuss.elastic.co/t/how-to-filter-limit-term-or-phrase-suggester-by-a-specific-field/99215/2 "2017-10-01T08:22:35Z")

</div>

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