refresh.asciidoc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. [[indices-refresh]]
  2. === Refresh API
  3. ++++
  4. <titleabbrev>Refresh</titleabbrev>
  5. ++++
  6. A refresh makes recent operations performed on one or more indices available for
  7. search. For data streams, the API runs the refresh operation on the stream's
  8. backing indices. For more information about the refresh operation, see
  9. <<near-real-time>>.
  10. [source,console]
  11. ----
  12. POST /my-index-000001/_refresh
  13. ----
  14. // TEST[setup:my_index]
  15. [[refresh-api-request]]
  16. ==== {api-request-title}
  17. `POST <target>/_refresh`
  18. `GET <target>/_refresh`
  19. `POST /_refresh`
  20. `GET /_refresh`
  21. [[refresh-api-prereqs]]
  22. ==== {api-prereq-title}
  23. * If the {es} {security-features} are enabled, you must have the `maintenance`
  24. or `manage` <<privileges-list-indices,index privilege>> for the target data
  25. stream, index, or alias.
  26. [[refresh-api-desc]]
  27. ==== {api-description-title}
  28. Use the refresh API to explicitly make all operations performed on one or more
  29. indices since the last refresh available for search.
  30. If the request targets a data stream, it refreshes the stream's backing indices.
  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. `<target>`::
  58. (Optional, string)
  59. Comma-separated list of data streams, indices, and aliases used to limit
  60. the request. Supports wildcards (`*`). To target all data streams and indices,
  61. omit this parameter or use `*` or `_all`.
  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. ----