elasticsearch,bulk,Asynchronous,elasticsearch,Bulk" /> elasticsearch,bulk,Asynchronous,elasticsearch,Bulk" />

Asynchronous Elasticsearch批量更新,然后进行搜索

Asynchronous Elasticsearch批量更新,然后进行搜索,asynchronous,elasticsearch,bulk,Asynchronous,elasticsearch,Bulk,在我的服务器中,我使用批量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"]}}}}}

在我的服务器中,我使用批量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"]}}}}}

但是返回的文档没有更新的值(仍然具有旧值)。如果我等待一段时间,将显示更新的值。我认为这是因为bulk是异步的?有没有办法解决这个问题?

您可以使用api强制索引更新,甚至在批量命令末尾添加
?refresh=true
。但通常不推荐。另外,如果有多个节点,您可能需要使用。

也可以将
refresh=true
参数添加到批量请求URL本身,即不需要为此进行第二次调用。@jirico我想是的,我找不到任何其他原因。