ElasticSearch7.2之refresh操作(将buffer缓冲区中的数据刷新到磁盘)

  • 理想的搜索:

新的数据⼀添加到索引中⽴⻢就能搜索到,但是真实情况不是这样的。

  • 我们使⽤链式命令请求,先添加⼀个⽂档,再⽴刻搜索

//插入数据

curl -X PUT localhost:9200/star/_doc/888 -H 'Content-Type:application/json' -d '{ "displayName": "蔡徐坤" }'

//查询数据
curl - X GET localhost : 9200 / star / _doc / _search ? pretty
 

结果肯定是搜索不到的。。。。。。

  • 强制刷新

//插入数据,传入参数  refresh
curl - X PUT localhost : 9200 / star / _doc / 666 ? refresh - H 'Content-Type:application/json' - d '{ "displayName": " 杨超越 " }'
//查询数据
curl - X GET localhost : 9200 / star / _doc / _search ? pretty
 
  • 修改默认更新时间(默认时间是1s)

PUT / star / _settings

{
    "index": {
        "refresh_interval": "5s"
    }
}

  • refresh关闭

PUT / star / _settings

{
    "index": {
        "refresh_interval": "-1"
    }
}

发布了92 篇原创文章 · 获赞 3 · 访问量 5149

猜你喜欢

转载自blog.csdn.net/qq_22049773/article/details/103244914