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
字段,显示的是多少就是在哪个分片。