flush.asciidoc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 index 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)
  46. Comma-separated list of data streams, indices, and index aliases to flush.
  47. Wildcard expressions (`*`) are supported.
  48. +
  49. To flush all data streams and indices in a cluster, omit this parameter or use
  50. `_all` or `*`.
  51. [[flush-api-query-params]]
  52. ==== {api-query-parms-title}
  53. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
  54. +
  55. Defaults to `true`.
  56. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
  57. +
  58. Defaults to `open`.
  59. `force`::
  60. +
  61. --
  62. (Optional, Boolean)
  63. If `true`,
  64. the request forces a flush
  65. even if there are no changes to commit to the index.
  66. Defaults to `true`.
  67. You can use this parameter
  68. to increment the generation number of the transaction log.
  69. This parameter is considered internal.
  70. --
  71. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
  72. `wait_if_ongoing`::
  73. +
  74. --
  75. (Optional, Boolean)
  76. If `true`,
  77. the flush operation blocks until execution
  78. when another flush operation is running.
  79. If `false`,
  80. {es} returns an error
  81. if you request a flush
  82. when another flush operation is running.
  83. Defaults to `true`.
  84. --
  85. [[flush-api-example]]
  86. ==== {api-examples-title}
  87. [[flush-api-specific-ex]]
  88. ===== Flush a specific data stream or index
  89. [source,console]
  90. ----
  91. POST /my-index-000001/_flush
  92. ----
  93. // TEST[s/^/PUT my-index-000001\n/]
  94. [[flush-multi-index]]
  95. ===== Flush several data streams and indices
  96. [source,console]
  97. ----
  98. POST /my-index-000001,my-index-000002/_flush
  99. ----
  100. // TEST[s/^/PUT my-index-000001\nPUT my-index-000002\n/]
  101. [[flush-api-all-ex]]
  102. ===== Flush all data streams and indices in a cluster
  103. [source,console]
  104. ----
  105. POST /_flush
  106. ----