open-close.asciidoc 3.9 KB

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