Elasticsearch 批量更新后进行搜索

Elasticsearch bulk update followed by search

在我的服务器中,我使用批量更新了一些文档 API:

{"update":{"_type":"post","_retry_on_conflict":"3","_index":"xxxx","_id":"yyyy"}}
{"doc":{"sentiment":"positive","mood":1,"upgrade":true}}

收到回复后,我使用搜索对同一文档发出新请求:

{"query":{"filtered":{"filter":{"ids":{"values":["yyyy"]}}}}}

但是返回的文档没有更新值(仍然有旧值)。如果我等待一段时间,就会出现更新的值。我认为这是因为批量是异步的?有什么办法可以解决这个问题吗?

你可以使用 refresh api to force index update, or even add ?refresh=true at the end of bulk command. But normally not recommended. Also, If there are more than one Node, you may need to use synced flush.