open-close.asciidoc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. [[indices-open-close]]
  2. === Open / Close Index API
  3. The open and close index APIs allow to close an index, and later on
  4. opening it.
  5. A closed index is blocked for read/write operations and does not allow
  6. all operations that opened indices allow. It is not possible to index
  7. documents or to search for documents in a closed index. This allows
  8. closed indices to not have to maintain internal data structures for
  9. indexing or searching documents, resulting in a smaller overhead on
  10. the cluster.
  11. When opening or closing an index, the master is responsible for
  12. restarting the index shards to reflect the new state of the index.
  13. The shards will then go through the normal recovery process. The
  14. data of opened/closed indices is automatically replicated by the
  15. cluster to ensure that enough shard copies are safely kept around
  16. at all times.
  17. The REST endpoint is `/{index}/_close` and `/{index}/_open`.
  18. The following example shows how to close an index:
  19. [source,js]
  20. --------------------------------------------------
  21. POST /my_index/_close
  22. --------------------------------------------------
  23. // CONSOLE
  24. // TEST[s/^/PUT my_index\n/]
  25. This will return the following response:
  26. [source,js]
  27. --------------------------------------------------
  28. {
  29. "acknowledged" : true,
  30. "shards_acknowledged" : true,
  31. "indices" : {
  32. "my_index" : {
  33. "closed" : true
  34. }
  35. }
  36. }
  37. --------------------------------------------------
  38. // TESTRESPONSE
  39. A closed index can be reopened like this:
  40. [source,js]
  41. --------------------------------------------------
  42. POST /my_index/_open
  43. --------------------------------------------------
  44. // CONSOLE
  45. // TEST[s/^/PUT my_index\nPOST my_index\/_close\n/]
  46. which will yield the following response:
  47. [source,js]
  48. --------------------------------------------------
  49. {
  50. "acknowledged" : true,
  51. "shards_acknowledged" : true
  52. }
  53. --------------------------------------------------
  54. // TESTRESPONSE
  55. It is possible to open and close multiple indices. An error will be thrown
  56. if the request explicitly refers to a missing index. This behaviour can be
  57. disabled using the `ignore_unavailable=true` parameter.
  58. All indices can be opened or closed at once using `_all` as the index name
  59. or specifying patterns that identify them all (e.g. `*`).
  60. Identifying indices via wildcards or `_all` can be disabled by setting the
  61. `action.destructive_requires_name` flag in the config file to `true`.
  62. This setting can also be changed via the cluster update settings api.
  63. 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
  64. API by setting `cluster.indices.close.enable` to `false`. The default is `true`.
  65. [float]
  66. ==== Wait For Active Shards
  67. Because opening or closing an index allocates its shards, the
  68. <<create-index-wait-for-active-shards,`wait_for_active_shards`>> setting on
  69. index creation applies to the `_open` and `_close` index actions as well.