segments.asciidoc 5.4 KB

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