open-close.asciidoc 4.3 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-prereqs]]
  18. ==== {api-prereq-title}
  19. * If the {es} {security-features} are enabled, you must have the `manage`
  20. <<privileges-list-indices,index privilege>> for the target data stream, index,
  21. or index alias.
  22. [[open-index-api-desc]]
  23. ==== {api-description-title}
  24. You can use the open index API to re-open closed indices. If the request targets
  25. a data stream, the request re-opens any of the stream's closed backing indices.
  26. // tag::closed-index[]
  27. A closed index is blocked for read/write operations and does not allow
  28. all operations that opened indices allow. It is not possible to index
  29. documents or to search for documents in a closed index. This allows
  30. closed indices to not have to maintain internal data structures for
  31. indexing or searching documents, resulting in a smaller overhead on
  32. the cluster.
  33. When opening or closing an index, the master is responsible for
  34. restarting the index shards to reflect the new state of the index.
  35. The shards will then go through the normal recovery process. The
  36. data of opened/closed indices is automatically replicated by the
  37. cluster to ensure that enough shard copies are safely kept around
  38. at all times.
  39. You can open and close multiple indices. An error is thrown
  40. if the request explicitly refers to a missing index. This behaviour can be
  41. disabled using the `ignore_unavailable=true` parameter.
  42. By default, you must explicitly name the indices you are opening or closing.
  43. To open or close indices with `_all`, `*`, or other wildcard
  44. expressions, change the `action.destructive_requires_name` setting to `false`.
  45. This setting can also be changed via the cluster update settings api.
  46. Closed indices consume a significant amount of disk-space which can cause
  47. problems in managed environments. Closing indices can be disabled via the cluster settings
  48. API by setting `cluster.indices.close.enable` to `false`. The default is `true`.
  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. +
  65. By default, you must explicitly name the indices you using to limit the request.
  66. To limit a request using `_all`, `*`, or other wildcard
  67. expressions, change the `action.destructive_requires_name` setting to `false`.
  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. --------------------------------------------------