|
| 1 | +--- |
| 2 | +mapped_pages: |
| 3 | + - https://www.elastic.co/guide/en/elasticsearch/reference/8.18/indices-disk-usage.html |
| 4 | +applies_to: |
| 5 | + serverless: unavailable |
| 6 | + stack: all |
| 7 | +navigation_title: Analyze index disk usage |
| 8 | +--- |
| 9 | + |
| 10 | +# Analyze index disk usage API example |
| 11 | + |
| 12 | +The `_disk_usage` API analyzes how much disk space each field in an index or data stream consumes. It helps you understand storage distribution and identify fields that use the most space. This page shows an example request and response for the [Analyze index disk usage API]({{es-apis}}operation/operation-indices-disk-usage). |
| 13 | + |
| 14 | +## Example request |
| 15 | + |
| 16 | +The following request analyzes the disk usage of the index `my-index-000001`: |
| 17 | + |
| 18 | +```console |
| 19 | +POST /my-index-000001/_disk_usage?run_expensive_tasks=true |
| 20 | +``` |
| 21 | +% TEST[setup:messages] |
| 22 | + |
| 23 | +## Example response |
| 24 | + |
| 25 | +The API returns: |
| 26 | + |
| 27 | +```console-response |
| 28 | +{ |
| 29 | + "_shards": { |
| 30 | + "total": 1, |
| 31 | + "successful": 1, |
| 32 | + "failed": 0 |
| 33 | + }, |
| 34 | + "my-index-000001": { |
| 35 | + "store_size": "929mb", <1> |
| 36 | + "store_size_in_bytes": 974192723, |
| 37 | + "all_fields": { |
| 38 | + "total": "928.9mb", <2> |
| 39 | + "total_in_bytes": 973977084, |
| 40 | + "inverted_index": { |
| 41 | + "total": "107.8mb", |
| 42 | + "total_in_bytes": 113128526 |
| 43 | + }, |
| 44 | + "stored_fields": "623.5mb", |
| 45 | + "stored_fields_in_bytes": 653819143, |
| 46 | + "doc_values": "125.7mb", |
| 47 | + "doc_values_in_bytes": 131885142, |
| 48 | + "points": "59.9mb", |
| 49 | + "points_in_bytes": 62885773, |
| 50 | + "norms": "2.3kb", |
| 51 | + "norms_in_bytes": 2356, |
| 52 | + "term_vectors": "2.2kb", |
| 53 | + "term_vectors_in_bytes": 2310, |
| 54 | + "knn_vectors": "0b", |
| 55 | + "knn_vectors_in_bytes": 0 |
| 56 | + }, |
| 57 | + "fields": { |
| 58 | + "_id": { |
| 59 | + "total": "49.3mb", |
| 60 | + "total_in_bytes": 51709993, |
| 61 | + "inverted_index": { |
| 62 | + "total": "29.7mb", |
| 63 | + "total_in_bytes": 31172745 |
| 64 | + }, |
| 65 | + "stored_fields": "19.5mb", <3> |
| 66 | + "stored_fields_in_bytes": 20537248, |
| 67 | + "doc_values": "0b", |
| 68 | + "doc_values_in_bytes": 0, |
| 69 | + "points": "0b", |
| 70 | + "points_in_bytes": 0, |
| 71 | + "norms": "0b", |
| 72 | + "norms_in_bytes": 0, |
| 73 | + "term_vectors": "0b", |
| 74 | + "term_vectors_in_bytes": 0, |
| 75 | + "knn_vectors": "0b", |
| 76 | + "knn_vectors_in_bytes": 0 |
| 77 | + }, |
| 78 | + "_primary_term": {...}, |
| 79 | + "_seq_no": {...}, |
| 80 | + "_version": {...}, |
| 81 | + "_source": { |
| 82 | + "total": "603.9mb", |
| 83 | + "total_in_bytes": 633281895, |
| 84 | + "inverted_index": {...}, |
| 85 | + "stored_fields": "603.9mb", <4> |
| 86 | + "stored_fields_in_bytes": 633281895, |
| 87 | + "doc_values": "0b", |
| 88 | + "doc_values_in_bytes": 0, |
| 89 | + "points": "0b", |
| 90 | + "points_in_bytes": 0, |
| 91 | + "norms": "0b", |
| 92 | + "norms_in_bytes": 0, |
| 93 | + "term_vectors": "0b", |
| 94 | + "term_vectors_in_bytes": 0, |
| 95 | + "knn_vectors": "0b", |
| 96 | + "knn_vectors_in_bytes": 0 |
| 97 | + }, |
| 98 | + "context": { |
| 99 | + "total": "28.6mb", |
| 100 | + "total_in_bytes": 30060405, |
| 101 | + "inverted_index": { |
| 102 | + "total": "22mb", |
| 103 | + "total_in_bytes": 23090908 |
| 104 | + }, |
| 105 | + "stored_fields": "0b", |
| 106 | + "stored_fields_in_bytes": 0, |
| 107 | + "doc_values": "0b", |
| 108 | + "doc_values_in_bytes": 0, |
| 109 | + "points": "0b", |
| 110 | + "points_in_bytes": 0, |
| 111 | + "norms": "2.3kb", |
| 112 | + "norms_in_bytes": 2356, |
| 113 | + "term_vectors": "2.2kb", |
| 114 | + "term_vectors_in_bytes": 2310, |
| 115 | + "knn_vectors": "0b", |
| 116 | + "knn_vectors_in_bytes": 0 |
| 117 | + }, |
| 118 | + "context.keyword": {...}, |
| 119 | + "message": {...}, |
| 120 | + "message.keyword": {...} |
| 121 | + } |
| 122 | + } |
| 123 | +} |
| 124 | +``` |
| 125 | + |
| 126 | +% TESTRESPONSE[s/: \{\.\.\.\}/: $body.$_path/] |
| 127 | +% TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/] |
| 128 | +% TESTRESPONSE[s/: "[^"]*"/: $body.$_path/] |
| 129 | + |
| 130 | +1. The total disk space used by the shards analyzed by the API. By default, only primary shards are analyzed. |
| 131 | + |
| 132 | +2. The total disk space used by all fields in the analyzed shards. This total is usually smaller than the `store_size` annotated in <1>, because the API ignores some metadata files. |
| 133 | + |
| 134 | +3. The disk space used by `_id` field values for direct document retrieval. This storage enables [getting a document by its ID]({{es-apis}}operation/operation-get), without needing to search the inverted index. |
| 135 | + |
| 136 | +4. The disk space used by the `_source` field. As stored fields are stored |
| 137 | +together in a compressed format, the sizes of stored fields are |
| 138 | +estimates and can be inaccurate. The stored size of the `_id` field |
| 139 | +is likely underestimated while the `_source` field is overestimated. |
0 commit comments