blocks.asciidoc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 and removes the read-only index block automatically when
  32. the disk utilization falls below the high watermark, controlled by
  33. <<cluster-routing-flood-stage,cluster.routing.allocation.disk.watermark.flood_stage>>.
  34. `index.blocks.read`::
  35. Set to `true` to disable read operations against the index.
  36. `index.blocks.write`::
  37. Set to `true` to disable data write operations against the index. Unlike
  38. `read_only`, this setting does not affect metadata. For instance, you can
  39. adjust the settings of an index with a `write` block, but you cannot adjust
  40. the settings of an index with a `read_only` block.
  41. `index.blocks.metadata`::
  42. Set to `true` to disable index metadata reads and writes.
  43. [discrete]
  44. [[add-index-block]]
  45. === Add index block API
  46. Adds an index block to an index.
  47. [source,console]
  48. --------------------------------------------------
  49. PUT /my-index-000001/_block/write
  50. --------------------------------------------------
  51. // TEST[setup:my_index]
  52. [discrete]
  53. [[add-index-block-api-request]]
  54. ==== {api-request-title}
  55. `PUT /<index>/_block/<block>`
  56. [discrete]
  57. [role="child_attributes"]
  58. [[add-index-block-api-path-params]]
  59. ==== {api-path-parms-title}
  60. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index]
  61. +
  62. By default, you must explicitly name the indices you are adding blocks to.
  63. To allow the adding of blocks to indices with `_all`, `*`, or other wildcard
  64. expressions, change the `action.destructive_requires_name` setting to `false`.
  65. You can update this setting in the `elasticsearch.yml` file
  66. or using the <<cluster-update-settings,cluster update settings>> API.
  67. `<block>`::
  68. (Required, string)
  69. Block type to add to the index.
  70. +
  71. .Valid values for `<block>`
  72. [%collapsible%open]
  73. ====
  74. `metadata`::
  75. Disable metadata changes, such as closing the index.
  76. `read`::
  77. Disable read operations.
  78. `read_only`::
  79. Disable write operations and metadata changes.
  80. `write`::
  81. Disable write operations. However, metadata changes are still allowed.
  82. ====
  83. [discrete]
  84. [[add-index-block-api-query-params]]
  85. ==== {api-query-parms-title}
  86. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
  87. +
  88. Defaults to `true`.
  89. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
  90. +
  91. Defaults to `open`.
  92. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
  93. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  94. [discrete]
  95. [[add-index-block-api-example]]
  96. ==== {api-examples-title}
  97. The following example shows how to add an index block:
  98. [source,console]
  99. --------------------------------------------------
  100. PUT /my-index-000001/_block/write
  101. --------------------------------------------------
  102. // TEST[s/^/PUT my-index-000001\n/]
  103. The API returns following response:
  104. [source,console-result]
  105. --------------------------------------------------
  106. {
  107. "acknowledged" : true,
  108. "shards_acknowledged" : true,
  109. "indices" : [ {
  110. "name" : "my-index-000001",
  111. "blocked" : true
  112. } ]
  113. }
  114. --------------------------------------------------