flush.asciidoc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. [[indices-flush]]
  2. === Flush API
  3. ++++
  4. <titleabbrev>Flush</titleabbrev>
  5. ++++
  6. Flushes one or more data streams or indices.
  7. [source,console]
  8. --------------------------------------------------
  9. POST /my-index-000001/_flush
  10. --------------------------------------------------
  11. // TEST[setup:my_index]
  12. [[flush-api-request]]
  13. ==== {api-request-title}
  14. `POST /<target>/_flush`
  15. `GET /<target>/_flush`
  16. `POST /_flush`
  17. `GET /_flush`
  18. [[flush-api-prereqs]]
  19. ==== {api-prereq-title}
  20. * If the {es} {security-features} are enabled, you must have the `maintenance`
  21. or `manage` <<privileges-list-indices,index privilege>> for the target data
  22. stream, index, or alias.
  23. [[flush-api-desc]]
  24. ==== {api-description-title}
  25. Flushing a data stream or index is the process of making sure that any data that is currently
  26. only stored in the <<index-modules-translog,transaction log>> is also
  27. permanently stored in the Lucene index. When restarting, {es} replays any
  28. unflushed operations from the transaction log in to the Lucene index to bring it
  29. back into the state that it was in before the restart. {es} automatically
  30. triggers flushes as needed, using heuristics that trade off the size of the
  31. unflushed transaction log against the cost of performing each flush.
  32. Once each operation has been flushed it is permanently stored in the Lucene
  33. index. This may mean that there is no need to maintain an additional copy of it
  34. in the transaction log. The transaction log is made up of multiple files,
  35. called _generations_, and {es} will delete any generation files once they are no
  36. longer needed, freeing up disk space.
  37. It is also possible to trigger a flush on one or more indices using the flush
  38. API, although it is rare for users to need to call this API directly. If you
  39. call the flush API after indexing some documents then a successful response
  40. indicates that {es} has flushed all the documents that were indexed before the
  41. flush API was called.
  42. [[flush-api-path-params]]
  43. ==== {api-path-parms-title}
  44. `<target>`::
  45. (Optional, string) Comma-separated list of data streams, indices, and aliases to
  46. flush. Supports wildcards (`*`). To flush all data streams and indices, omit
  47. this parameter or use `*` or `_all`.
  48. [[flush-api-query-params]]
  49. ==== {api-query-parms-title}
  50. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
  51. +
  52. Defaults to `true`.
  53. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
  54. +
  55. Defaults to `open`.
  56. `force`::
  57. +
  58. --
  59. (Optional, Boolean)
  60. If `true`,
  61. the request forces a flush
  62. even if there are no changes to commit to the index.
  63. Defaults to `true`.
  64. You can use this parameter
  65. to increment the generation number of the transaction log.
  66. This parameter is considered internal.
  67. --
  68. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
  69. `wait_if_ongoing`::
  70. +
  71. --
  72. (Optional, Boolean)
  73. If `true`,
  74. the flush operation blocks until execution
  75. when another flush operation is running.
  76. If `false`,
  77. {es} returns an error
  78. if you request a flush
  79. when another flush operation is running.
  80. Defaults to `true`.
  81. --
  82. [[flush-api-example]]
  83. ==== {api-examples-title}
  84. [[flush-api-specific-ex]]
  85. ===== Flush a specific data stream or index
  86. [source,console]
  87. ----
  88. POST /my-index-000001/_flush
  89. ----
  90. // TEST[s/^/PUT my-index-000001\n/]
  91. [[flush-multi-index]]
  92. ===== Flush several data streams and indices
  93. [source,console]
  94. ----
  95. POST /my-index-000001,my-index-000002/_flush
  96. ----
  97. // TEST[s/^/PUT my-index-000001\nPUT my-index-000002\n/]
  98. [[flush-api-all-ex]]
  99. ===== Flush all data streams and indices in a cluster
  100. [source,console]
  101. ----
  102. POST /_flush
  103. ----