clearcache.asciidoc 3.0 KB

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