refresh.asciidoc 2.5 KB

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