索引/更新的弹性搜索延迟

时间:2016-01-11 06:35:58

标签: elasticsearch

我有以下三步交易:

(1)Insert User basic info(id,name).
(2)Search the User Id. 
(3)If found the user,then update the record with user behavior info.

所以我使用elasticSearch.index()API插入用户ID和名称,然后使用elasticSearch.search()API查询它,如果找到,我将通过elasticSearch.update()API更新记录。但ES延迟会导致search()API无法获取任何内容,即使数据已被索引。 所以关于修复此问题的任何想法,谢谢!

1 个答案:

答案 0 :(得分:1)

默认情况下,索引每秒刷新一次,但您可以使用Refresh API强制刷新并确保新索引的数据可用。

curl -XPOST 'http://localhost:9200/users/_refresh'

请注意,可以将其调用以进行测试,但不应在生产群集上执行此操作,因为这可能会导致性能问题。

相关问题