使用批量端点索引文档时,可以设置参数
refresh=wait_for
以等待分片刷新。
我想要做的是禁用索引刷新间隔,发送所有批量请求,最后调用刷新端点
POST /{index}/_refresh
,然后等待所有刷新完成。
是否可以使用操作系统的API来完成?
我搜索了文档,但找不到执行此操作的方法。
您可以通过将
refresh_interval
调整为 -1
来禁用刷新操作。您可以对 _all
索引进行操作,也可以仅对其中之一进行操作。
如果您想加快索引速度,您还可以检查 以下文档。 https://www.elastic.co/guide/en/elasticsearch/reference/current/tune-for-indexing-speed.html
#disable the refresh
PUT index/_settings
{
"refresh_interval": "-1"
}
#complete the bulk
POST /index/_bulk
#re-enable the refresh
PUT index/_settings
{
"refresh_interval": null
}
#or just refresh manually
POST index/_refresh
多久执行一次刷新操作, 使最近对索引的更改对搜索可见。默认为 1 秒。 可以设置为 -1 以禁用刷新。如果这个设置没有明确 设置,至少没有看到搜索流量的分片 index.search.idle.after 秒不会收到后台刷新 直到他们收到搜索请求。命中空闲分片的搜索 当刷新处于挂起状态时,将触发刷新作为 仅针对该分片的搜索操作。这种行为的目的是 没有时默认情况下自动优化批量索引 执行搜索。为了选择退出此行为 应将刷新间隔显式设置为 1s。 https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html#index-refresh-interval-settingindex.refresh_interval