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,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 problems in managed environments. Closing indices can be disabled via the cluster settings
  41. API by setting `cluster.indices.close.enable` to `false`. The default is `true`.
  42. ===== Wait For active shards
  43. Because opening or closing an index allocates its shards, the
  44. <<create-index-wait-for-active-shards,`wait_for_active_shards`>> setting on
  45. index creation applies to the `_open` and `_close` index actions as well.
  46. // end::closed-index[]
  47. [[open-index-api-path-params]]
  48. ==== {api-path-parms-title}
  49. include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
  50. +
  51. To open all indices, use `_all` or `*`.
  52. To disallow the opening of indices with `_all` or wildcard expressions,
  53. change the `action.destructive_requires_name` cluster setting to `true`.
  54. You can update this setting in the `elasticsearch.yml` file
  55. or using the <<cluster-update-settings,cluster update settings>> API.
  56. [[open-index-api-query-params]]
  57. ==== {api-query-parms-title}
  58. include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
  59. +
  60. Defaults to `true`.
  61. include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
  62. +
  63. Defaults to `closed`.
  64. include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
  65. include::{docdir}/rest-api/common-parms.asciidoc[tag=wait_for_active_shards]
  66. include::{docdir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  67. [[open-index-api-example]]
  68. ==== {api-examples-title}
  69. A closed index can be re-opened like this:
  70. [source,console]
  71. --------------------------------------------------
  72. POST /my_index/_open
  73. --------------------------------------------------
  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. --------------------------------------------------