分析索引磁盘使用情况 API
编辑分析索引磁盘使用情况 API
编辑此功能为技术预览版,可能会在未来的版本中更改或删除。Elastic 将努力修复任何问题,但技术预览版中的功能不受官方 GA 功能的支持 SLA 约束。
分析索引或数据流中每个字段的磁盘使用情况。此 API 可能不支持在以前的 Elasticsearch 版本中创建的索引。小型索引的结果可能不准确,因为 API 可能不会分析索引的某些部分。
resp = client.indices.disk_usage( index="my-index-000001", run_expensive_tasks=True, ) print(resp)
response = client.indices.disk_usage( index: 'my-index-000001', run_expensive_tasks: true ) puts response
const response = await client.indices.diskUsage({ index: "my-index-000001", run_expensive_tasks: "true", }); console.log(response);
POST /my-index-000001/_disk_usage?run_expensive_tasks=true
请求
编辑POST /<target>/_disk_usage
路径参数
编辑-
<target>
- (必需,字符串)用于限制请求的数据流、索引和别名的逗号分隔列表。建议使用单个索引(或数据流的最新后备索引)执行此 API,因为该 API 会显著消耗资源。
查询参数
编辑-
allow_no_indices
-
(可选,布尔值)如果为
false
,则当任何通配符表达式、索引别名或_all
值仅以丢失或关闭的索引为目标时,请求将返回错误。即使请求以其他打开的索引为目标,此行为也适用。例如,如果索引以foo
开头,但没有索引以bar
开头,则以foo*,bar*
为目标的请求将返回错误。默认为
true
。 -
expand_wildcards
-
(可选,字符串)通配符模式可以匹配的索引类型。如果请求可以以数据流为目标,则此参数确定通配符表达式是否匹配隐藏数据流。支持逗号分隔的值,例如
open,hidden
。有效值有:-
all
- 匹配任何数据流或索引,包括隐藏的那些。
-
open
- 匹配打开的非隐藏索引。也匹配任何非隐藏的数据流。
-
closed
- 匹配关闭的非隐藏索引。也匹配任何非隐藏的数据流。数据流无法关闭。
-
hidden
- 匹配隐藏的数据流和隐藏的索引。必须与
open
、closed
或两者组合使用。 -
none
- 不接受通配符模式。
默认为
open
。 -
-
flush
- (可选,布尔值)如果为
true
,则 API 在分析之前执行刷新。如果为false
,则响应可能不包含未提交的数据。默认为true
。 -
ignore_unavailable
- (可选,布尔值)如果为
false
,则当请求以丢失或关闭的索引为目标时,请求将返回错误。默认为false
。 -
run_expensive_tasks
- (必需,布尔值)分析字段磁盘使用情况是资源密集型的。要使用 API,此参数必须设置为
true
。默认为false
。 -
wait_for_active_shards
-
(可选,字符串)在继续操作之前,必须处于活动状态的每个分片的副本数。设置为
all
或任何非负整数,最大为索引中每个分片副本的总数(number_of_replicas+1
)。默认为1
,这意味着仅等待每个主分片处于活动状态。请参阅 活动分片。
示例
编辑resp = client.indices.disk_usage( index="my-index-000001", run_expensive_tasks=True, ) print(resp)
response = client.indices.disk_usage( index: 'my-index-000001', run_expensive_tasks: true ) puts response
const response = await client.indices.diskUsage({ index: "my-index-000001", run_expensive_tasks: "true", }); console.log(response);
POST /my-index-000001/_disk_usage?run_expensive_tasks=true
API 返回:
{ "_shards": { "total": 1, "successful": 1, "failed": 0 }, "my-index-000001": { "store_size": "929mb", "store_size_in_bytes": 974192723, "all_fields": { "total": "928.9mb", "total_in_bytes": 973977084, "inverted_index": { "total": "107.8mb", "total_in_bytes": 113128526 }, "stored_fields": "623.5mb", "stored_fields_in_bytes": 653819143, "doc_values": "125.7mb", "doc_values_in_bytes": 131885142, "points": "59.9mb", "points_in_bytes": 62885773, "norms": "2.3kb", "norms_in_bytes": 2356, "term_vectors": "2.2kb", "term_vectors_in_bytes": 2310, "knn_vectors": "0b", "knn_vectors_in_bytes": 0 }, "fields": { "_id": { "total": "49.3mb", "total_in_bytes": 51709993, "inverted_index": { "total": "29.7mb", "total_in_bytes": 31172745 }, "stored_fields": "19.5mb", "stored_fields_in_bytes": 20537248, "doc_values": "0b", "doc_values_in_bytes": 0, "points": "0b", "points_in_bytes": 0, "norms": "0b", "norms_in_bytes": 0, "term_vectors": "0b", "term_vectors_in_bytes": 0, "knn_vectors": "0b", "knn_vectors_in_bytes": 0 }, "_primary_term": {...}, "_seq_no": {...}, "_version": {...}, "_source": { "total": "603.9mb", "total_in_bytes": 633281895, "inverted_index": {...}, "stored_fields": "603.9mb", "stored_fields_in_bytes": 633281895, "doc_values": "0b", "doc_values_in_bytes": 0, "points": "0b", "points_in_bytes": 0, "norms": "0b", "norms_in_bytes": 0, "term_vectors": "0b", "term_vectors_in_bytes": 0, "knn_vectors": "0b", "knn_vectors_in_bytes": 0 }, "context": { "total": "28.6mb", "total_in_bytes": 30060405, "inverted_index": { "total": "22mb", "total_in_bytes": 23090908 }, "stored_fields": "0b", "stored_fields_in_bytes": 0, "doc_values": "0b", "doc_values_in_bytes": 0, "points": "0b", "points_in_bytes": 0, "norms": "2.3kb", "norms_in_bytes": 2356, "term_vectors": "2.2kb", "term_vectors_in_bytes": 2310, "knn_vectors": "0b", "knn_vectors_in_bytes": 0 }, "context.keyword": {...}, "message": {...}, "message.keyword": {...} } } }