refresh.asciidoc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. [[indices-refresh]]
  2. === Refresh API
  3. ++++
  4. <titleabbrev>Refresh</titleabbrev>
  5. ++++
  6. Refreshes one or more indices. For data streams, the API refreshes the stream's
  7. backing indices.
  8. [source,console]
  9. ----
  10. POST /my-index-000001/_refresh
  11. ----
  12. // TEST[setup:my_index]
  13. [[refresh-api-request]]
  14. ==== {api-request-title}
  15. `POST <target>/_refresh`
  16. `GET <target>/_refresh`
  17. `POST /_refresh`
  18. `GET /_refresh`
  19. [[refresh-api-prereqs]]
  20. ==== {api-prereq-title}
  21. * If the {es} {security-features} are enabled, you must have the `maintenance`
  22. or `manage` <<privileges-list-indices,index privilege>> for the target data
  23. stream, index, or index alias.
  24. [[refresh-api-desc]]
  25. ==== {api-description-title}
  26. Use the refresh API to explicitly refresh one or more indices.
  27. If the request targets a data stream, it refreshes the stream's backing indices.
  28. A _refresh_ makes all operations performed on an index
  29. since the last refresh
  30. available for search.
  31. // tag::refresh-interval-default[]
  32. By default, Elasticsearch periodically refreshes indices every second, but only on
  33. indices that have received one search request or more in the last 30 seconds.
  34. // end::refresh-interval-default[]
  35. You can change this default interval
  36. using the <<index-refresh-interval-setting,`index.refresh_interval`>> setting.
  37. Refresh requests are synchronous and do not return a response until the
  38. refresh operation completes.
  39. [IMPORTANT]
  40. ====
  41. Refreshes are resource-intensive.
  42. To ensure good cluster performance,
  43. we recommend waiting for {es}'s periodic refresh
  44. rather than performing an explicit refresh
  45. when possible.
  46. If your application workflow
  47. indexes documents and then runs a search
  48. to retrieve the indexed document,
  49. we recommend using the <<docs-index_,index API>>'s
  50. `refresh=wait_for` query parameter option.
  51. This option ensures the indexing operation waits
  52. for a periodic refresh
  53. before running the search.
  54. ====
  55. [[refresh-api-path-params]]
  56. ==== {api-path-parms-title}
  57. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index]
  58. +
  59. To refresh all indices in the cluster,
  60. omit this parameter
  61. or use a value of `_all` or `*`.
  62. [[refresh-api-query-params]]
  63. ==== {api-query-parms-title}
  64. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
  65. +
  66. Defaults to `true`.
  67. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
  68. +
  69. Defaults to `open`.
  70. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
  71. [[refresh-api-example]]
  72. ==== {api-examples-title}
  73. [[refresh-api-multiple-ex]]
  74. ===== Refresh several data streams and indices
  75. [source,console]
  76. ----
  77. POST /my-index-000001,my-index-000002/_refresh
  78. ----
  79. // TEST[s/^/PUT my-index-000001\nPUT my-index-000002\n/]
  80. [[refresh-api-all-ex]]
  81. ===== Refresh all data streams and indices in a cluster
  82. [source,console]
  83. ----
  84. POST /_refresh
  85. ----