es 710 更新时设置realtime为true
在ES 7.10中,可以通过在索引模板中设置realtime参数为true来启用实时刷新。实时刷新意味着当索引文档时,文档将立即对搜索可见,而不需要等待刷新间隔。
以下是一个示例的索引模板配置:
PUT _index_template/my_template
{
"index_patterns": ["my_index*"],
"template": {
"settings": {
"index": {
"refresh_interval": "1s",
"number_of_shards": 1,
"number_of_replicas": 1
}
},
"mappings": {
"properties": {
"message": {
"type": "text"
}
}
}
},
"priority": 100,
"composed_of": []
}
在上述示例中,refresh_interval设置为1s,这意味着每秒将进行一次刷新。此外,我们没有显式设置realtime参数,因为在ES 7.10中,默认值为true。
请注意,在高负载环境中启用实时刷新可能会对性能产生一定的影响。因此,您应该根据您的特定用例和硬件配置来评估是否需要启用实时刷新
原文地址: https://www.cveoy.top/t/topic/iN4d 著作权归作者所有。请勿转载和采集!