从5.0.0版开始,elasticsearch有一个选项:
?refresh=wait_for
在索引,更新,删除和批量api上。这样,在结果在ElasticSearch中可见之前,请求将不会收到响应。(好极了!)
有关更多信息,请参见https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-
refresh.html。
编辑:似乎此功能已经是最新的Python elasticsearch api的一部分:https :
//elasticsearch-
py.readthedocs.io/en/master/api.html#elasticsearch.Elasticsearch.index
将您的elasticsearch.update更改为:
elasticsearch.update( index='blog', doc_type='blog' id=1, refresh='wait_for', body={ .... })而且您不需要任何睡眠或轮询。



