1
0

blocks.asciidoc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. [[index-modules-blocks]]
  2. == Index blocks
  3. Index blocks limit the kind of operations that are available on a certain
  4. index. The blocks come in different flavours, allowing to block write,
  5. read, or metadata operations. The blocks can be set / removed using dynamic
  6. index settings, or can be added using a dedicated API, which also ensures
  7. for write blocks that, once successfully returning to the user, all shards
  8. of the index are properly accounting for the block, for example that all
  9. in-flight writes to an index have been completed after adding the write
  10. block.
  11. [discrete]
  12. [[index-block-settings]]
  13. === Index block settings
  14. The following _dynamic_ index settings determine the blocks present on an
  15. index:
  16. `index.blocks.read_only`::
  17. Set to `true` to make the index and index metadata read only, `false` to
  18. allow writes and metadata changes.
  19. `index.blocks.read_only_allow_delete`::
  20. Similar to `index.blocks.read_only`, but also allows deleting the index to
  21. make more resources available. The <<disk-based-shard-allocation,disk-based shard
  22. allocator>> may add and remove this block automatically.
  23. +
  24. Deleting documents from an index to release resources - rather than deleting the index itself - can increase the index size over time. When `index.blocks.read_only_allow_delete` is set to `true`, deleting documents is not permitted. However, deleting the index itself releases the read-only index block and makes resources available almost immediately.
  25. +
  26. IMPORTANT: {es} adds and removes the read-only index block automatically when the disk utilization falls below the high watermark, controlled by <<cluster-routing-flood-stage,cluster.routing.allocation.disk.watermark.flood_stage>>.
  27. `index.blocks.read`::
  28. Set to `true` to disable read operations against the index.
  29. `index.blocks.write`::
  30. Set to `true` to disable data write operations against the index. Unlike `read_only`,
  31. this setting does not affect metadata. For instance, you can close an index with a `write`
  32. block, but you cannot close an index with a `read_only` block.
  33. `index.blocks.metadata`::
  34. Set to `true` to disable index metadata reads and writes.
  35. `index.blocks.read_only_allow_delete`::
  36. Similar to `index.blocks.read_only`, but also allows deleting the index to
  37. make more resources available. The <<disk-based-shard-allocation,disk-based shard
  38. allocator>> adds and removes this block automatically.
  39. Deleting documents from an index - rather than deleting the index itself - can
  40. in fact increase the index size. When you are running out of disk space
  41. `index.blocks.read_only_allow_delete` is set to `true`, preventing you from
  42. consuming more disk space by deleting some documents. However, this block does
  43. permit you to delete the index itself since this does not require any extra
  44. disk space. When you delete an index the data is removed from disk almost
  45. immediately, freeing the space it consumes.
  46. IMPORTANT: {es} adds the read-only-allow-delete index block automatically when
  47. disk utilisation exceeds the <<cluster-routing-flood-stage,flood-stage
  48. watermark>> and removes it again when disk utilisation is below the
  49. <<cluster-routing-watermark-high,high watermark>>. You should not apply this
  50. block yourself.
  51. [discrete]
  52. [[add-index-block]]
  53. === Add index block API
  54. Adds an index block to an index.
  55. [source,console]
  56. --------------------------------------------------
  57. PUT /my-index-000001/_block/write
  58. --------------------------------------------------
  59. // TEST[setup:my_index]
  60. [discrete]
  61. [[add-index-block-api-request]]
  62. ==== {api-request-title}
  63. `PUT /<index>/_block/<block>`
  64. [discrete]
  65. [role="child_attributes"]
  66. [[add-index-block-api-path-params]]
  67. ==== {api-path-parms-title}
  68. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index]
  69. +
  70. To add blocks to all indices, use `_all` or `*`. To disallow the adding
  71. of blocks to indices with `_all` or wildcard expressions,
  72. change the `action.destructive_requires_name` cluster setting to `true`.
  73. You can update this setting in the `elasticsearch.yml` file
  74. or using the <<cluster-update-settings,cluster update settings>> API.
  75. `<block>`::
  76. (Required, string)
  77. Block type to add to the index.
  78. +
  79. .Valid values for `<block>`
  80. [%collapsible%open]
  81. ====
  82. `metadata`::
  83. Disable metadata changes, such as closing the index.
  84. `read`::
  85. Disable read operations.
  86. `read_only`::
  87. Disable write operations and metadata changes.
  88. `write`::
  89. Disable write operations. However, metadata changes are still allowed.
  90. ====
  91. [discrete]
  92. [[add-index-block-api-query-params]]
  93. ==== {api-query-parms-title}
  94. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
  95. +
  96. Defaults to `true`.
  97. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
  98. +
  99. Defaults to `open`.
  100. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
  101. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  102. [discrete]
  103. [[add-index-block-api-example]]
  104. ==== {api-examples-title}
  105. The following example shows how to add an index block:
  106. [source,console]
  107. --------------------------------------------------
  108. PUT /my-index-000001/_block/write
  109. --------------------------------------------------
  110. // TEST[s/^/PUT my-index-000001\n/]
  111. The API returns following response:
  112. [source,console-result]
  113. --------------------------------------------------
  114. {
  115. "acknowledged" : true,
  116. "shards_acknowledged" : true,
  117. "indices" : [ {
  118. "name" : "my-index-000001",
  119. "blocked" : true
  120. } ]
  121. }
  122. --------------------------------------------------