<p dir="auto">// CREATE INDEX<br>
curl -X PUT -d '{<br>
"number_of_shards" : 1,<br>
"number_of_replicas" : 1<br>
}' "<a href="http://localhost:9200/services" rel="nofollow">http://localhost:9200/services</a>"</p>
<p dir="auto">// MAPPING<br>
curl -X PUT -d '{<br>
"service": {<br>
"properties": {<br>
"name": {<br>
"type": "string",<br>
"index": "not_analyzed"<br>
},<br>
"pin": {<br>
"type":"geo_point"<br>
},<br>
"currentstatus": {<br>
"type": "string",<br>
"index": "not_analyzed"<br>
},<br>
"suggest_field": {<br>
"type": "completion",<br>
"context": {<br>
"status": {<br>
"type": "category",<br>
"default": "bad",<br>
"path": "currentstatus"<br>
},<br>
"location": {<br>
"type": "geo",<br>
"precision": "100km",<br>
"neighbors": true,<br>
"path":"pin",<br>
"default": {<br>
"lat": 0.0,<br>
"lon": 0.0<br>
}<br>
}<br>
}<br>
}<br>
}<br>
}<br>
}' "<a href="http://localhost:9200/services/service/_mapping" rel="nofollow">http://localhost:9200/services/service/_mapping</a>"</p>
<p dir="auto">// Insert record<br>
curl -X PUT -d '{<br>
"name": "knapsack",<br>
"pin": {<br>
"lat": 47.620499,<br>
"lon": -122.350876<br>
},<br>
"currentstatus" : "good",<br>
"suggest_field": {<br>
"input": [<br>
"knacksack",<br>
"backpack",<br>
"daypack"<br>
]<br>
}<br>
}' "<a href="http://localhost:9200/services/service/1" rel="nofollow">http://localhost:9200/services/service/1</a>"</p>
<p dir="auto">// Suggest<br>
curl -X POST -d '{<br>
"suggest": {<br>
"text": "k",<br>
"completion": {<br>
"field": "suggest_field",<br>
"size": 10,<br>
"context": {<br>
"location": {<br>
"lat": 47.482880,<br>
"lon": -122.217064,<br>
"precision":"100km"<br>
},<br>
"status": "good"<br>
}<br>
}<br>
}<br>
}' "<a href="http://localhost:9200/services/_suggest" rel="nofollow">http://localhost:9200/services/_suggest</a>"</p>
<p dir="auto">You'd expect that we'd get a suggestion here. When I do the category completion alone, it works correctly but it doesn't seem to get the lat/lon from the path but rather always uses the default. I don't want to have to duplicate data and this is not working as expected. What is going wrong here?</p>
<p dir="auto">Currently the Completion &amp; Context Suggesters suggests from documents that were deleted but not still merged away by Lucene. Ideally the suggesters should never suggest from deleted documents.</p>
<p dir="auto">The solution is to encode lucene docids in the generated FST used by suggesters, and filter out suggestions from deleted documents at query time. This approach would also allow us to make use of the lucene docids to make the suggesters more flexible in terms of returning fields not specified at 'index' time in the future. This approach also implies changing how the FSTs are built currently (i.e. dedup-ing same surface forms might not make sense anymore, as each entry will be tied to a lucene doc).</p>
<p dir="auto"><strong>NOTE:</strong> this is an issue for <code class="notranslate">feature/nrt_suggester</code></p>