ElasticSearch之Clear cache API

发布时间 2023-12-02 10:52:47作者: jackieathome

本方法用于清理缓存。

命令样例如下:

curl -X POST "https://localhost:9200/testindex_001/_cache/clear?pretty" --cacert $ES_HOME/config/certs/http_ca.crt -u "elastic:ohCxPH=QBE+s5=*lo7F9"

执行结果的样例,如下:

{
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  }
}

方法参数
fielddata,默认值为false

  • true,清理字段相关的缓存。
  • false,不清理字段的缓存。

fields,默认值为全部字段,否则只清理指定的字段。

ignore_unavailable,默认值为false

  • true,本操作执行时跳过失效或者不可用的index
  • false,本操作执行时,遇到失效或者不可用的index,则报错,样例如下:
    {
      "error" : {
          "root_cause" : [
          {
              "type" : "index_not_found_exception",
              "reason" : "no such index [testindex_002]",
              "resource.type" : "index_or_alias",
              "resource.id" : "testindex_002",
              "index_uuid" : "_na_",
              "index" : "testindex_002"
          }
          ],
          "type" : "index_not_found_exception",
          "reason" : "no such index [testindex_002]",
          "resource.type" : "index_or_alias",
          "resource.id" : "testindex_002",
          "index_uuid" : "_na_",
          "index" : "testindex_002"
      },
      "status" : 404
    }
    

query,默认值为false

  • true,清理query的缓存。
  • false

request,默认值为false

  • true,清理request的缓存。
  • false

相关资料