open-close.asciidoc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. [[indices-open-close]]
  2. === Open index API
  3. ++++
  4. <titleabbrev>Open index</titleabbrev>
  5. ++++
  6. Opens a closed index. For data streams, the API
  7. opens any closed backing indices.
  8. [source,console]
  9. --------------------------------------------------
  10. POST /my-index-000001/_open
  11. --------------------------------------------------
  12. // TEST[setup:my_index]
  13. // TEST[s/^/POST \/my-index-000001\/_close\n/]
  14. [[open-index-api-request]]
  15. ==== {api-request-title}
  16. `POST /<target>/_open`
  17. [[open-index-api-desc]]
  18. ==== {api-description-title}
  19. You can use the open index API to re-open closed indices. If the request targets
  20. a data stream, the request re-opens any of the stream's closed backing indices.
  21. // tag::closed-index[]
  22. A closed index is blocked for read/write operations and does not allow
  23. all operations that opened indices allow. It is not possible to index
  24. documents or to search for documents in a closed index. This allows
  25. closed indices to not have to maintain internal data structures for
  26. indexing or searching documents, resulting in a smaller overhead on
  27. the cluster.
  28. When opening or closing an index, the master is responsible for
  29. restarting the index shards to reflect the new state of the index.
  30. The shards will then go through the normal recovery process. The
  31. data of opened/closed indices is automatically replicated by the
  32. cluster to ensure that enough shard copies are safely kept around
  33. at all times.
  34. You can open and close multiple indices. An error is thrown
  35. if the request explicitly refers to a missing index. This behaviour can be
  36. disabled using the `ignore_unavailable=true` parameter.
  37. All indices can be opened or closed at once using `_all` as the index name
  38. or specifying patterns that identify them all (e.g. `*`).
  39. Identifying indices via wildcards or `_all` can be disabled by setting the
  40. `action.destructive_requires_name` flag in the config file to `true`.
  41. This setting can also be changed via the cluster update settings api.
  42. Closed indices consume a significant amount of disk-space which can cause
  43. problems in managed environments. Closing indices can be disabled via the cluster settings
  44. API by setting `cluster.indices.close.enable` to `false`. The default is `true`.
  45. The current write index on a data stream cannot be closed. In order to close
  46. the current write index, the data stream must first be
  47. <<rollover-data-stream-ex,rolled over>> so that a new write index is created
  48. and then the previous write index can be closed.
  49. // end::closed-index[]
  50. [[open-index-api-wait-for-active-shards]]
  51. ===== Wait For active shards
  52. // tag::wait-for-active-shards[]
  53. Because opening or closing an index allocates its shards, the
  54. <<create-index-wait-for-active-shards,`wait_for_active_shards`>> setting on
  55. index creation applies to the `_open` and `_close` index actions as well.
  56. // end::wait-for-active-shards[]
  57. [[open-index-api-path-params]]
  58. ==== {api-path-parms-title}
  59. `<target>`::
  60. (Optional, string)
  61. Comma-separated list of data streams, indices, and index aliases used to limit
  62. the request. Wildcard (`*`) expressions are supported.
  63. +
  64. To target all data streams and indices, use `_all` or `*`.
  65. +
  66. To disallow use of `_all` or wildcard expressions,
  67. change the `action.destructive_requires_name` cluster setting to `true`.
  68. You can update this setting in the `elasticsearch.yml` file
  69. or using the <<cluster-update-settings,cluster update settings>> API.
  70. [[open-index-api-query-params]]
  71. ==== {api-query-parms-title}
  72. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
  73. +
  74. Defaults to `true`.
  75. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
  76. +
  77. Defaults to `closed`.
  78. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
  79. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=wait_for_active_shards]
  80. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  81. [[open-index-api-example]]
  82. ==== {api-examples-title}
  83. The following request re-opens a closed index named `my-index-000001`.
  84. [source,console]
  85. --------------------------------------------------
  86. POST /my-index-000001/_open
  87. --------------------------------------------------
  88. // TEST[s/^/PUT my-index-000001\nPOST my-index-000001\/_close\n/]
  89. The API returns the following response:
  90. [source,console-result]
  91. --------------------------------------------------
  92. {
  93. "acknowledged" : true,
  94. "shards_acknowledged" : true
  95. }
  96. --------------------------------------------------