flush.asciidoc 3.3 KB

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