I have defined my mapping for index autocomplete as
{ "mappings": { "panels": { "properties": { "dealer": { "type": "completion" }, "county": { "type": "completion", "contexts": [{ "name": "dealername", "type": "category", "path": "dealername" }, { "name": "statename", "type": "category", "path": "statename" } ] }, "state": { "type": "completion", "contexts": [{ "name": "dealername", "type": "category", "path": "dealername" }] }, "dealername":{ "type": "keyword" }, "statename":{ "type": "keyword" }, "countyname":{ "type": "keyword" }, "meid": { "type": "text" } } } } }
When I am trying to fetch completion suggestion on field dealer as dealer2 I am getting
curl -X POST "########:9200/autocomplete/_search?pretty" -H 'Content-Type: application/json' -d' { "suggest": { "state_suggestion_for_dealer" : { "prefix" : "dealer2", "completion" : { "field" : "dealer", "size": 10 } } } } '
I am getting results as
{ "text" : "dealer3", "_index" : "autocomplete", "_type" : "panels", "_id" : "#########", "_score" : 1.0, "_source" : { "dealer" : { "input" : [ "dealer3" ] }, "state" : { "input" : [ "Virginia" ], "contexts" : { "dealername" : [ "dealer3" ] } }, "county" : { "input" : [ "Park" ], "contexts" : { "dealername" : [ "dealer3" ], "statename" : [ "Virginia" ] } }, "dealername" : "dealer3", "statename" : "Virginia", "countyname" : "Park", "meid" : "###########" } } As in the curl request I had specified delaer2 i should not get dealer3 results in suggestion .