flush.asciidoc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. [[indices-flush]]
  2. === Flush API
  3. ++++
  4. <titleabbrev>Flush</titleabbrev>
  5. ++++
  6. Flushes one or more indices.
  7. [source,console]
  8. --------------------------------------------------
  9. POST /twitter/_flush
  10. --------------------------------------------------
  11. // TEST[setup:twitter]
  12. [[flush-api-request]]
  13. ==== {api-request-title}
  14. `POST /<index>/_flush`
  15. `GET /<index>/_flush`
  16. `POST /_flush`
  17. `GET /_flush`
  18. [[flush-api-desc]]
  19. ==== {api-description-title}
  20. Flushing an 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, unless <<index-modules-translog-retention,it is retained
  30. for some other reason>>. The transaction log is made up of multiple files,
  31. called _generations_, and {es} will delete any generation files once they are no
  32. longer needed, freeing up disk space.
  33. It is also possible to trigger a flush on one or more indices using the flush
  34. API, although it is rare for users to need to call this API directly. If you
  35. call the flush API after indexing some documents then a successful response
  36. indicates that {es} has flushed all the documents that were indexed before the
  37. flush API was called.
  38. [[flush-api-path-params]]
  39. ==== {api-path-parms-title}
  40. include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
  41. +
  42. To flush all indices,
  43. omit this parameter
  44. or use a value of `_all` or `*`.
  45. [[flush-api-query-params]]
  46. ==== {api-query-parms-title}
  47. include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
  48. include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
  49. +
  50. Defaults to `open`.
  51. `force`::
  52. +
  53. --
  54. (Optional, boolean)
  55. If `true`,
  56. the request forces a flush
  57. even if there are no changes to commit to the index.
  58. Defaults to `true`.
  59. You can use this parameter
  60. to increment the generation number of the transaction log.
  61. This parameter is considered internal.
  62. --
  63. include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
  64. `wait_if_ongoing`::
  65. +
  66. --
  67. (Optional, boolean)
  68. If `true`,
  69. the flush operation blocks until execution
  70. when another flush operation is running.
  71. If `false`,
  72. {es} returns an error
  73. if you request a flush
  74. when another flush operation is running.
  75. Defaults to `true`.
  76. --
  77. [[flush-api-example]]
  78. ==== {api-examples-title}
  79. [[flush-api-specific-ex]]
  80. ===== Flush a specific index
  81. [source,console]
  82. ----
  83. POST /kimchy/_flush
  84. ----
  85. // TEST[s/^/PUT kimchy\n/]
  86. [[flush-multi-index]]
  87. ===== Flush several indices
  88. [source,console]
  89. ----
  90. POST /kimchy,elasticsearch/_flush
  91. ----
  92. // TEST[s/^/PUT kimchy\nPUT elasticsearch\n/]
  93. [[flush-api-all-ex]]
  94. ===== Flush all indices
  95. [source,console]
  96. ----
  97. POST /_flush
  98. ----