clearcache.asciidoc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. [[indices-clearcache]]
  2. === Clear cache API
  3. ++++
  4. <titleabbrev>Clear cache</titleabbrev>
  5. ++++
  6. Clears the caches of one or more indices. For data streams, the API clears the
  7. caches of the stream's backing indices.
  8. [source,console]
  9. ----
  10. POST /my-index-000001/_cache/clear
  11. ----
  12. // TEST[setup:my_index]
  13. [[clear-cache-api-request]]
  14. ==== {api-request-title}
  15. `POST /<target>/_cache/clear`
  16. `POST /_cache/clear`
  17. [[clear-cache-api-prereqs]]
  18. ==== {api-prereq-title}
  19. * If the {es} {security-features} are enabled, you must have the `manage`
  20. <<privileges-list-indices,index privilege>> for the target data stream, index,
  21. or index alias.
  22. [[clear-cache-api-path-params]]
  23. ==== {api-path-parms-title}
  24. `<target>`::
  25. (Optional, string)
  26. Comma-separated list of data streams, indices, and index aliases used to limit
  27. the request. Wildcard expressions (`*`) are supported.
  28. +
  29. To target all data streams and indices in a cluster, omit this parameter or use
  30. `_all` or `*`.
  31. [[clear-cache-api-query-params]]
  32. ==== {api-query-parms-title}
  33. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
  34. +
  35. Defaults to `true`.
  36. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
  37. +
  38. Defaults to `open`.
  39. `fielddata`::
  40. +
  41. --
  42. (Optional, Boolean)
  43. If `true`,
  44. clears the fields cache.
  45. Use the `fields` parameter
  46. to clear the cache of specific fields only.
  47. --
  48. `fields`::
  49. +
  50. --
  51. (Optional, string)
  52. Comma-separated list of field names
  53. used to limit the `fielddata` parameter.
  54. Defaults to all fields.
  55. NOTE: This parameter does *not* support objects
  56. or field aliases.
  57. --
  58. `index`::
  59. (Optional, string)
  60. Comma-separated list of index names
  61. used to limit the request.
  62. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
  63. `query`::
  64. (Optional, Boolean)
  65. If `true`,
  66. clears the query cache.
  67. `request`::
  68. (Optional, Boolean)
  69. If `true`,
  70. clears the request cache.
  71. [[clear-cache-api-example]]
  72. ==== {api-examples-title}
  73. [[clear-cache-api-specific-ex]]
  74. ===== Clear a specific cache
  75. By default,
  76. the clear cache API clears all caches.
  77. You can clear only specific caches
  78. by setting the following query parameters to `true`:
  79. * `fielddata`
  80. * `query`
  81. * `request`
  82. [source,console]
  83. ----
  84. POST /my-index-000001/_cache/clear?fielddata=true <1>
  85. POST /my-index-000001/_cache/clear?query=true <2>
  86. POST /my-index-000001/_cache/clear?request=true <3>
  87. ----
  88. // TEST[continued]
  89. <1> Clears only the fields cache
  90. <2> Clears only the query cache
  91. <3> Clears only the request cache
  92. [[clear-cache-api-specific-fields-ex]]
  93. ===== Clear the cache of specific fields
  94. To only clear the cache of specific fields,
  95. use the `fields` query parameter.
  96. [source,console]
  97. ----
  98. POST /my-index-000001/_cache/clear?fields=foo,bar <1>
  99. ----
  100. // TEST[continued]
  101. <1> Clear the cache for the `foo` and `bar` field
  102. [[clear-cache-api-multi-ex]]
  103. ===== Clear caches for several data streams and indices
  104. [source,console]
  105. ----
  106. POST /my-index-000001,my-index-000002/_cache/clear
  107. ----
  108. // TEST[s/^/PUT my-index-000001\nPUT my-index-000002\n/]
  109. [[clear-cache-api-all-ex]]
  110. ===== Clear caches for all data streams and indices
  111. [source,console]
  112. ----
  113. POST /_cache/clear
  114. ----