elasticseach的分片有很多時,如果我想查詢下某個文檔當前所在分片,該如何查詢?
GET /saas_product_batch_stock_test/_search_shards?routing=ZHL10184670,ZHL10174592,ZHL10180859
注意routing
支持多個,使用英文逗號分割。該參數就是你設置的路由,如果沒有改變路由值,默認就是_id。其結果如下:
{
"nodes" : {
"Ea27RhxZSwe-i1d1_e4byQ" : {
// ...
},
"1YhLR1HJQbS6lPQk439fRQ" : {
// ...
},
"cmF1BIKfQZi7lFLgOtqAyg" : {
// ...
}
},
"indices" : {
"saas_product_batch_stock_test" : { }
},
"shards" : [
[
{
"state" : "STARTED",
"primary" : true,
"node" : "1YhLR1HJQbS6lPQk439fRQ",
"relocating_node" : null,
"shard" : 6,
"index" : "saas_product_batch_stock_test",
"allocation_id" : {
"id" : "cRRTzzKkTGeOusLCLq3aYw"
}
}
],
[
{
"state" : "STARTED",
"primary" : true,
"node" : "cmF1BIKfQZi7lFLgOtqAyg",
"relocating_node" : null,
"shard" : 7,
"index" : "saas_product_batch_stock_test",
"allocation_id" : {
"id" : "87Vbsw9iT4aNIJU02u2JGg"
}
}
],
[
{
"state" : "STARTED",
"primary" : true,
"node" : "Ea27RhxZSwe-i1d1_e4byQ",
"relocating_node" : null,
"shard" : 10,
"index" : "saas_product_batch_stock_test",
"allocation_id" : {
"id" : "d6i5xK2_TmynvjV5CFlLgw"
}
}
]
]
}
重點關注shard
字段,顯示的是多少就是在哪個分片。