segments.asciidoc 5.5 KB

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