blocks.asciidoc 4.8 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`, except that you can delete the index when
  22. this block is in place. Do not set or remove this block yourself. The
  23. <<disk-based-shard-allocation,disk-based shard allocator>> sets and removes
  24. this block automatically according to the available disk space.
  25. +
  26. Deleting documents from an index to release resources - rather than deleting
  27. the index itself - increases the index size temporarily, and therefore may not
  28. be possible when nodes are low on disk space. When
  29. `index.blocks.read_only_allow_delete` is set to `true`, deleting documents is
  30. not permitted. However, deleting the index entirely requires very little extra
  31. disk space and frees up the disk space consumed by the index almost immediately
  32. so this is still permitted.
  33. +
  34. IMPORTANT: {es} adds the read-only-allow-delete index block automatically when
  35. the disk utilization exceeds the flood stage watermark, and removes this block
  36. automatically when the disk utilization falls under the high watermark. See
  37. <<disk-based-shard-allocation,Disk-based shard allocation>> for more
  38. information about watermarks, and <<fix-watermark-errors,Fix watermark errors>>
  39. for help with resolving watermark issues.
  40. `index.blocks.read`::
  41. Set to `true` to disable read operations against the index.
  42. [[index-blocks-write]]
  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-ref-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-ref-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
  94. +
  95. Defaults to `true`.
  96. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
  97. +
  98. Defaults to `open`.
  99. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
  100. include::{es-ref-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. --------------------------------------------------