涉及API
index、insert、update、bulk
示例
es_client.index(index="news", document=document, refresh=True)
es_client.update(index="news", id=path.id, doc=body.dict(exclude_none=True), refresh=True)
refresh解释
:param refresh:
If ‘true’, Elasticsearch refreshes the affected shards to make this operation visible to search,
if ‘wait_for’ then wait for a refresh to make this operation visible to search,
if ‘false’ do nothing with refreshes.
- 如果为“true”,将刷新受影响的碎片此操作对搜索可见(直白的讲就是:直接写盘存储)
- 如果为’wait_for’,则等待刷新以使此操作对于搜索可见(直白的讲就是:等待异步写盘存储完成)
- 如果为’false’,则不执行刷新操作(直白的讲就是:啥也不做)
refresh接受的类型(默认值为false):
- 字符串:true,false,wait_for
- 布尔值:True,False
- None等同于False