Match query with suggestion search


(Ankur Singla) #1

I have created a mapping of index searchable:

PUT searchable
{
    "mappings": {
        "searchCol" : {
            "properties" : {
                "suggest" : {
                    "type" : "completion"
                },
                "title" : {
                    "type": "keyword"
                }
            }
        }
    }
}

with some documents title wise:

PUT music/song/2?refresh
{
    "suggest" :  [ "val", "value", "val of", "value of" ],
    "title" : "a"
}

I want to search suggestion only in particular titled documents such that in title:a documents. But match is not working with suggest.

POST music/_search?pretty&size=1
{
  "query" : {"match":{"title": "a"}},
    "suggest": {
        "suggestion" : {
            "prefix" : "val", 
            "completion" : { 
                "field" : "suggest"
            }
        }
    }
}

Still searching in all documents. Is there any way to do it?


(Luiz Santos) #2

Hi @ankur_singla,

The completion suggester is not filtered by the query, it considers all documents in the index. Please take a look in Context Suggester it might do the job you are looking for.

Cheers,
LG


(Ankur Singla) #3

thanxs.


(system) #4

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