segments.asciidoc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. [[indices-segments]]
  2. === Index segments API
  3. ++++
  4. <titleabbrev>Index segments</titleabbrev>
  5. ++++
  6. Returns low-level information about the https://lucene.apache.org/core/[Lucene]
  7. segments in index shards. For data streams, the API returns information about
  8. the stream's backing indices.
  9. [source,console]
  10. ----
  11. GET /my-index-000001/_segments
  12. ----
  13. // TEST[setup:my_index]
  14. [[index-segments-api-request]]
  15. ==== {api-request-title}
  16. `GET /<target>/_segments`
  17. `GET /_segments`
  18. [[index-segments-api-path-params]]
  19. ==== {api-path-parms-title}
  20. `<target>`::
  21. (Optional, string)
  22. Comma-separated list of data streams, indices, and index aliases used to limit
  23. the request. Wildcard expressions (`*`) are supported.
  24. +
  25. To target all data streams and indices in a cluster, omit this parameter or use
  26. `_all` or `*`.
  27. [[index-segments-api-query-params]]
  28. ==== {api-query-parms-title}
  29. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
  30. +
  31. Defaults to `true`.
  32. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
  33. +
  34. Defaults to `open`.
  35. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
  36. `verbose`::
  37. experimental:[]
  38. (Optional, boolean)
  39. If `true`, the response includes detailed information
  40. about Lucene's memory usage.
  41. Defaults to `false`.
  42. [[index-segments-api-response-body]]
  43. ==== {api-response-body-title}
  44. `<segment>`::
  45. (String)
  46. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=segment]
  47. `generation`::
  48. (Integer)
  49. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=generation]
  50. `num_docs`::
  51. (Integer)
  52. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=docs-count]
  53. `deleted_docs`::
  54. (Integer)
  55. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=docs-deleted]
  56. `size_in_bytes`::
  57. (Integer)
  58. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=segment-size]
  59. `memory_in_bytes`::
  60. (Integer)
  61. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=memory]
  62. `committed`::
  63. (Boolean)
  64. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=committed]
  65. `search`::
  66. (Boolean)
  67. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=segment-search]
  68. `version`::
  69. (String)
  70. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=segment-version]
  71. `compound`::
  72. (Boolean)
  73. If `true`, Lucene merged all files from the segment
  74. into a single file to save file descriptors.
  75. `attributes`::
  76. (Object)
  77. Contains information about whether high compression was enabled.
  78. [[index-segments-api-example]]
  79. ==== {api-examples-title}
  80. ===== Get segment information for a specific data stream or index
  81. [source,console]
  82. --------------------------------------------------
  83. GET /test/_segments
  84. --------------------------------------------------
  85. // TEST[s/^/PUT test\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST test\/_doc\?refresh\n{"test": "test"}\n/]
  86. ===== Get segment information for several data streams and indices
  87. [source,console]
  88. --------------------------------------------------
  89. GET /test1,test2/_segments
  90. --------------------------------------------------
  91. // TEST[s/^/PUT test1\nPUT test2\n/]
  92. ===== Get segment information for all data streams and indices in a cluster
  93. [source,console]
  94. --------------------------------------------------
  95. GET /_segments
  96. --------------------------------------------------
  97. // TEST[s/^/PUT test\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST test\/_doc\?refresh\n{"test": "test"}\n/]
  98. The API returns the following response:
  99. [source,console-response]
  100. --------------------------------------------------
  101. {
  102. "_shards": ...
  103. "indices": {
  104. "test": {
  105. "shards": {
  106. "0": [
  107. {
  108. "routing": {
  109. "state": "STARTED",
  110. "primary": true,
  111. "node": "zDC_RorJQCao9xf9pg3Fvw"
  112. },
  113. "num_committed_segments": 0,
  114. "num_search_segments": 1,
  115. "segments": {
  116. "_0": {
  117. "generation": 0,
  118. "num_docs": 1,
  119. "deleted_docs": 0,
  120. "size_in_bytes": 3800,
  121. "memory_in_bytes": 1410,
  122. "committed": false,
  123. "search": true,
  124. "version": "7.0.0",
  125. "compound": true,
  126. "attributes": {
  127. }
  128. }
  129. }
  130. }
  131. ]
  132. }
  133. }
  134. }
  135. }
  136. --------------------------------------------------
  137. // TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards,/]
  138. // TESTRESPONSE[s/"node": "zDC_RorJQCao9xf9pg3Fvw"/"node": $body.$_path/]
  139. // TESTRESPONSE[s/"attributes": \{[^}]*\}/"attributes": $body.$_path/]
  140. // TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/]
  141. // TESTRESPONSE[s/7\.0\.0/$body.$_path/]
  142. ===== Verbose mode
  143. To add additional information that can be used for debugging,
  144. use the `verbose` flag.
  145. experimental::[]
  146. [source,console]
  147. --------------------------------------------------
  148. GET /test/_segments?verbose=true
  149. --------------------------------------------------
  150. // TEST[continued]
  151. The API returns the following response:
  152. [source,console-response]
  153. --------------------------------------------------
  154. {
  155. ...
  156. "_0": {
  157. ...
  158. "ram_tree": [
  159. {
  160. "description": "postings [PerFieldPostings(format=1)]",
  161. "size_in_bytes": 2696,
  162. "children": [
  163. {
  164. "description": "format 'Lucene50_0' ...",
  165. "size_in_bytes": 2608,
  166. "children" :[ ... ]
  167. },
  168. ...
  169. ]
  170. },
  171. ...
  172. ]
  173. }
  174. ...
  175. }
  176. --------------------------------------------------
  177. // TESTRESPONSE[skip:Response is too verbose to be fully shown in documentation, so we just show the relevant bit and don't test the response.]