blocks.asciidoc 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. `index.blocks.read_only`::
  18. Set to `true` to make the index and index metadata read only, `false` to
  19. allow writes and metadata changes.
  20. `index.blocks.read_only_allow_delete`::
  21. Similar to `index.blocks.write`, but also allows deleting the index to
  22. make more resources available. The <<disk-based-shard-allocation,disk-based shard
  23. allocator>> may add and remove this block automatically.
  24. +
  25. Deleting documents from an index to release resources - rather than deleting
  26. the index itself - can increase the index size over time. When
  27. `index.blocks.read_only_allow_delete` is set to `true`, deleting documents is
  28. not permitted. However, deleting the index itself releases the read-only index
  29. block and makes resources available almost immediately.
  30. +
  31. IMPORTANT: {es} adds the read-only index block automatically when the disk
  32. utilization exceeds the flood stage watermark, controlled by the
  33. <<cluster-routing-flood-stage,cluster.routing.allocation.disk.watermark.flood_stage>>
  34. and <<cluster-routing-flood-stage,cluster.routing.allocation.disk.watermark.flood_stage.max_headroom>>
  35. settings, and removes the block automatically when the disk utilization falls
  36. under the high watermark, controlled by the
  37. <<cluster-routing-flood-stage,cluster.routing.allocation.disk.watermark.high>>
  38. and <<cluster-routing-flood-stage,cluster.routing.allocation.disk.watermark.high.max_headroom>>
  39. settings. Refer to <<fix-watermark-errors,Fix watermark errors>> to resolve
  40. watermark issues.
  41. `index.blocks.read`::
  42. Set to `true` to disable read operations against the index.
  43. `index.blocks.write`::
  44. Set to `true` to disable data write operations against the index. Unlike
  45. `read_only`, this setting does not affect metadata. For instance, you can
  46. adjust the settings of an index with a `write` block, but you cannot adjust
  47. the settings of an index with a `read_only` block.
  48. `index.blocks.metadata`::
  49. Set to `true` to disable index metadata reads and writes.
  50. [discrete]
  51. [[add-index-block]]
  52. === Add index block API
  53. Adds an index block to an index.
  54. [source,console]
  55. --------------------------------------------------
  56. PUT /my-index-000001/_block/write
  57. --------------------------------------------------
  58. // TEST[setup:my_index]
  59. [discrete]
  60. [[add-index-block-api-request]]
  61. ==== {api-request-title}
  62. `PUT /<index>/_block/<block>`
  63. [discrete]
  64. [role="child_attributes"]
  65. [[add-index-block-api-path-params]]
  66. ==== {api-path-parms-title}
  67. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index]
  68. +
  69. By default, you must explicitly name the indices you are adding blocks to.
  70. To allow the adding of blocks to indices with `_all`, `*`, or other wildcard
  71. expressions, change the `action.destructive_requires_name` setting to `false`.
  72. You can update this setting in the `elasticsearch.yml` file
  73. or using the <<cluster-update-settings,cluster update settings>> API.
  74. `<block>`::
  75. (Required, string)
  76. Block type to add to the index.
  77. +
  78. .Valid values for `<block>`
  79. [%collapsible%open]
  80. ====
  81. `metadata`::
  82. Disable metadata changes, such as closing the index.
  83. `read`::
  84. Disable read operations.
  85. `read_only`::
  86. Disable write operations and metadata changes.
  87. `write`::
  88. Disable write operations. However, metadata changes are still allowed.
  89. ====
  90. [discrete]
  91. [[add-index-block-api-query-params]]
  92. ==== {api-query-parms-title}
  93. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
  94. +
  95. Defaults to `true`.
  96. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
  97. +
  98. Defaults to `open`.
  99. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
  100. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  101. [discrete]
  102. [[add-index-block-api-example]]
  103. ==== {api-examples-title}
  104. The following example shows how to add an index block:
  105. [source,console]
  106. --------------------------------------------------
  107. PUT /my-index-000001/_block/write
  108. --------------------------------------------------
  109. // TEST[s/^/PUT my-index-000001\n/]
  110. The API returns following response:
  111. [source,console-result]
  112. --------------------------------------------------
  113. {
  114. "acknowledged" : true,
  115. "shards_acknowledged" : true,
  116. "indices" : [ {
  117. "name" : "my-index-000001",
  118. "blocked" : true
  119. } ]
  120. }
  121. --------------------------------------------------