ElasticSearch系列---【清除索引缓存】
1.查看所有索引缓存
curl -u elastic:your_password -X GET "http://localhost:9200/_stats?pretty"
2.查看指定索引缓存
curl -u elastic:your_password -X GET "http://localhost:9200/my_index/_stats?pretty"
3.只看缓存相关部分
你可以指定字段,比如只看 fielddata / query_cache / request_cache:
curl -u elastic:your_password -X GET "http://localhost:9200/my_index/_stats/fielddata,query_cache,request_cache?pretty"
#经典返回片段
{
"_all" : {
"primaries" : {
"query_cache" : {
"memory_size_in_bytes" : 1024,
"hit_count" : 10,
"miss_count" : 5,
"evictions" : 0
},
"fielddata" : {
"memory_size_in_bytes" : 2048,
"evictions" : 0
},
"request_cache" : {
"memory_size_in_bytes" : 0,
"hit_count" : 0,
"miss_count" : 0,
"evictions" : 0
}
}
}
}
- memory_size_in_bytes:缓存占用内存
- hit_count / miss_count:缓存命中与未命中次数
- evictions:缓存被清理次数
4.清除所有索引缓存
curl -u elastic:your_password -X POST "http://localhost:9200/_cache/clear"
5. 清除指定索引缓存(例如 my_index)
curl -u elastic:your_password -X POST "http://localhost:9200/my_index/_cache/clear"
6. 只清除某类缓存
Elasticsearch 支持三种缓存:
- fielddata(字段数据缓存,用于排序/聚合)
- query(查询结果缓存)
- request(请求缓存)
你可以按需清理,比如只清除查询缓存:
curl -u elastic:your_password -X POST "http://localhost:9200/my_index/_cache/clear?query=true"
清除 fielddata:
curl -u elastic:your_password -X POST "http://localhost:9200/my_index/_cache/clear?fielddata=true"
清除 request cache:
curl -u elastic:your_password -X POST "http://localhost:9200/my_index/_cache/clear?request=true"
愿你走出半生,归来仍是少年!
浙公网安备 33010602011771号