open-close.asciidoc 3.6 KB

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