clearcache.asciidoc 2.8 KB

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