ElasticSearch Open/Close Index

ElasticSearch Open/Close Index

1、close index

2、open index

3、总结

针对部分索引,我们暂时不需要对其进行读写,可以临时关闭索引,以减少es服务器的开销

1、close index

#为索引添加一条数据
put  test/_doc/1
{
  "key":"value"
}


#关闭索引
POST test/_close

关闭的索引是不可以读写的

put  test/_doc/2
{
  "key":"value"
}


POST test/_search

POST test/_count


#以上操作都会报一下错误

{
  "error": {
    "root_cause": [
      {
        "type": "index_closed_exception",
        "reason": "closed",
        "index_uuid": "HpPqhbmhRfWGSR4FP2Ozaw",
        "index": "test"
      }
    ],
    "type": "index_closed_exception",
    "reason": "closed",
    "index_uuid": "HpPqhbmhRfWGSR4FP2Ozaw",
    "index": "test"
  },
  "status": 400
}

2、open index

POST test/_open
put  test/_doc/2
{
  "key":"value"
}


POST test/_search

POST test/_count

打开索引后,以上操作又恢复正常

3、总结

  • 索引关闭后, 对集群的相关开销基本降低为 0
  • 但是无法被读取和搜索
  • 当需要的时候, 可以重新打开,索引恢复正常

4、对人工智能感兴趣点下面链接

现在人工智能非常火爆,很多朋友都想学,但是一般的教程都是为博硕生准备的,太难看懂了。最近发现了一个非常适合小白入门的教程,不仅通俗易懂而且还很风趣幽默。所以忍不住分享一下给大家。点这里可以跳转到教程。

https://www.cbedai.net/u014646662

发布了139 篇原创文章 · 获赞 273 · 访问量 666万+

猜你喜欢

转载自blog.csdn.net/u014646662/article/details/103575093