I am using Elastic Search 5.6.
I am using the completion suggester to return results in a search field. I have mapped and index my documents successfully. I also am getting results that are close to the desired result.
In the docs, it's mentioned that a context could be implemented to boost and/or filter results seen here:
the completion suggester considers all documents in the index, but it is often desirable to serve suggestions filtered and/or boosted by some criteria.
My problem is, however, I'm receiving filtered results only....not simply boosted results. If I'm reading the docs right, I should be able to boost without filtering. Docs
This problem is evident in a simple example. Let's say the search query is "Portland". The user is Portland, ME so I would like to boost that result higher than Portland, OR. However, currently my context is filtering the results, so instead of Portland, ME and Portland, OR being returned, just Portland, ME is being returned because it's within the context zone.
Mapping:
{
"mappings": {
"destination" : {
"_all": {"enabled": false},
"properties" : {
"name": {
"type": "text"
},
"suggest": {
"type": "completion",
"analyzer": "simple",
"contexts": {
"name": "location",
"type": "geo",
"path": "location"
}
},
"type": {
"type" : "keyword"
},
"state": {
"type" : "keyword"
},
"location": {
"type": "geo_point",
"index": true
},
}
}
}
}
Example Indexed Document:
{
"name": "Portland",
"location": [
-70.25533,
43.66147
],
"suggest": {
"input": "Portland"
},
"state": "ME",
"type": "city"
}
Finally, my query:
{
"suggest": {
"query-suggest" : {
"prefix" : search_query,
"completion": {
"field" : "suggest",
"size": 10,
"contexts": {
"location": [
{
"lat": loc.latitude,
"lon": loc.longitude,
"precision": 1
},
{
"context": {
"lat": loc.latitude,
"lon": loc.longitude
},
"boost": 2
}
]
}
}
}
}
};
Depending on where the location is set, ES is only returning results within that's geo context. I want boosted values in that geo context, not filter. How can I get boosted values based on my geo context without filtering them thus returning the boosted values first, then the next highest scored documents which could possibly be outside the geo context.