- Notifications
You must be signed in to change notification settings - Fork 25.6k
Description
Hello to all!
I have a problem with documents holding completion suggestion fields: at some point, a document is removed, but its completion field remains.
This problem doesn't happen to all document inserted in the index, it only happened to me when I created documents with high ids.
My environment settings:
ElasticSearch version number: 1.0.0.Beta1
Lucene version: 4.5.1
In the following example, I create an index and insert two documents. One with a high id (id 3567245) and other with a low id (id 103). When I remove the
document with low id, its completion suggestion field still remains.
Note: if I change the high id from 3567245 to, for example, 700. The problem reported doesn't happen.
Create index, populate and remove one of the documents
curl -XDELETE 'localhost:9200/myindex' curl -X PUT localhost:9200/myindex curl -X PUT localhost:9200/myindex/mytype/_mapping -d '{ "mytype": { "properties": { "name": { "type": "string" }, "suggest-mytype": { "type": "completion", "payloads": true } } } }' curl -XPOST 'localhost:9200/_bulk' -d ' {"index":{"_index":"myindex","_type":"mytype","_id":3567245}} {"name":"Johnny","suggest-mytype":{"input":["Johnny"],"output":"Johnny","payload":{"_id":3567245}}} {"index":{"_index":"myindex","_type":"mytype","_id":103}} {"name":"Anderson","suggest-mytype":{"input":["Anderson"],"output":"Anderson","payload":{"_id":103}}} ' curl -XDELETE 'localhost:9200/myindex/_query' -d ' {"bool":{"should":[{"term":{"_id":{"value":103}}}]}} 'search 1: show everything from the index
curl -XPOST 'localhost:9200/myindex/_search?pretty' -d '{}'Everything looks ok, the document with id 103 was removed:
{ "took" : 1, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 1, "max_score" : 1.0, "hits" : [ { "_index" : "myindex", "_type" : "mytype", "_id" : "3567245", "_score" : 1.0, "_source" : {"name":"Johnny","suggest-mytype":{"input":["Johnny"],"output":"Johnny","payload":{"_id":3567245}}} } ] } }search 2: look for suggestions
curl -XPOST 'localhost:9200/myindex/_suggest?pretty' -d '{ "completion1": { "text": "Jo", "completion": { "field": "suggest-mytype" } }, "completion2": { "text": "a", "completion": { "field": "suggest-mytype" } } }'Output for search 2:
{ "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "completion1" : [ { "text" : "Jo", "offset" : 0, "length" : 2, "options" : [ { "text" : "Johnny", "score" : 1.0, "payload" : {"_id":3567245} } ] } ], "completion2" : [ { "text" : "a", "offset" : 0, "length" : 1, "options" : [ { "text" : "Anderson", "score" : 1.0, "payload" : {"_id":103} } ] } ] }The entry with the id 103 was not supposed to show up here, because we removed the document.