python elasticsearch更新延迟问题

本文详细介绍了 Elasticsearch 中常见的 CRUD 操作,包括 index、insert、update 和 bulk 方法的使用方式,并重点解释了 refresh 参数的功能及其不同的设置选项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

涉及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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

llc的足迹

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值