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

(Ali Gholami) #1

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) 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?

(system) #2

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