Elasticsearch中的设置refresh_interval

在 Elasticsearch 中,refresh_interval 是一个 索引级别 的设置,用于控制 从内存缓冲区把新增/更新的文档刷到文件系统缓存(使其可搜索)的频率


🔍 一句话解释

它决定了 多久把"刚写入的数据"变成"立即可搜索的数据"


⚙️ 默认值

复制代码
"refresh_interval": "1s"
  • 默认每 1秒 执行一次 refresh。

  • 也就是说,默认情况下,新写入的文档最多延迟1秒就能被搜索到


🧪 参数说明

含义
"1s" 每1秒刷新一次(默认)
"30s" 每30秒刷新一次,降低I/O,提升写入吞吐量
"-1" 禁用自动刷新 ,需要手动调用 POST /my_index/_refresh 才能搜索到新数据

🧰 设置方法

创建索引时设置:
复制代码
PUT /my_index
{
  "settings": {
    "refresh_interval": "30s"
  }
}
动态修改(无需重启):
复制代码
PUT /my_index/_settings
{
  "refresh_interval": "30s"
}

✅ 使用场景建议

场景 推荐值 原因
实时搜索要求高(如电商搜索) "1s" 或更短 保证数据可见性
日志/批处理写入 "30s" 或更长 减少I/O,提升写入性能
大批量导入数据(如重建索引) 设置为 "-1",导入完成后手动 refresh 最大化写入吞吐量

🧠 小提示

  • 调大 refresh_interval 可以显著提升 bulk 写入速度,但会牺牲"实时性"。

  • 如果你在做 全量重建索引大批量导入 ,建议临时设置为 "-1",导入完再改回来。

相关推荐
阿里云大数据AI技术9 小时前
阿里云 ES AI 引擎版:面向 Agent 场景,为亿级租户、千亿规模向量设计的搜索引擎
人工智能·elasticsearch·agent
阿里云大数据AI技术10 小时前
FalconSeek 技术解析:阿里云 Elasticsearch 云原生内核如何让查询性能飙升600%
人工智能·elasticsearch
Elastic 中国社区官方博客10 小时前
将你的 Grafana Kubernetes 仪表板迁移到 Elastic Observability:相同的 PromQL,30 倍更快的查询
大数据·人工智能·elasticsearch·搜索引擎·容器·kubernetes·grafana
Elasticsearch12 小时前
使用重新设计的 AutoOps 更快地进行 Elasticsearch 问题排查
elasticsearch
Elastic 中国社区官方博客13 小时前
如何使用 OpenTelemetry 对你的搜索 API 进行埋点,并使用 ES|QL 对其进行查询
大数据·功能测试·elasticsearch·搜索引擎·全文检索·可用性测试
菜地里的小菜鸟1 天前
logstash定时同步elasticsearch数据
elasticsearch·数据同步·logstash定时同步elastics
BerryS3N1 天前
Code Git 工作树:多分支开发的痛点与工作树的曙光
大数据·git·elasticsearch
Elasticsearch1 天前
Elastic 与 Deductive AI 携手合作,加速工程团队的 agent 式事件调查
elasticsearch
Elasticsearch2 天前
将你的 Grafana Kubernetes 仪表板迁移到 Elastic Observability:相同的 PromQL,30 倍更快的查询
elasticsearch
爱莉希雅&&&2 天前
elasticsearch+kibana+logstash+filebeat链路部署流程
大数据·elasticsearch·搜索引擎·kibana·logstash·filebeat