ElasticSearch6.2.4(9)——使用mget批量查詢
阿新 • • 發佈:2019-02-07
1.mget批量查詢
使用第三章的資料
get /_mget
{
"docs":[
{
"_index":"zoo",
"_type":"product",
"_id":"1"
},
{
"_index":"zoo",
"_type":"product",
"_id":"2"
}
]
}
響應:
{
"docs": [
{
"_index": "zoo",
"_type": "product",
"_id": "1",
"_version": 1,
"found": true,
"_source": {
"name": "monkey",
"age": 10,
"content": "xiao small but ke ai"
}
},
{
"_index": "zoo",
"_type": "product",
"_id": "2",
"_version": 1,
"found": true,
"_source": {
"name": "monkey",
"age": 13,
"content": "xiao small but very big"
}
}
]
}
2.使用mget不同type查詢
先添加個資料
PUT /zoo/product1/1
{
"name": "11111",
"age": 333333333,
"content": "22222222222"
}
get /zoo/_mget
{
"docs":[
{
"_type":"product",
"_id":"1"
},
{
"_type":"product",
"_id":"2"
}
]
}
3.使用mget查詢不同id
get /zoo/product/_mget
{
"docs":[
{
"_id":"1"
},
{
"_id":"2"
}
]
}
使用第三章的資料
get /_mget
{
"docs":[
{
"_index":"zoo",
"_type":"product",
"_id":"1"
},
{
"_index":"zoo",
"_type":"product",
"_id":"2"
}
]
}
響應:
{
"docs": [
{
"_index": "zoo",
"_type": "product",
"_id": "1",
"_version": 1,
"found": true,
"_source": {
"name": "monkey",
"age": 10,
"content": "xiao small but ke ai"
}
},
{
"_index": "zoo",
"_type": "product",
"_id": "2",
"_version": 1,
"found": true,
"_source": {
"name": "monkey",
"age": 13,
"content": "xiao small but very big"
}
}
]
}
2.使用mget不同type查詢
先添加個資料
PUT /zoo/product1/1
{
"name": "11111",
"age": 333333333,
"content": "22222222222"
}
get /zoo/_mget
{
"docs":[
{
"_type":"product",
"_id":"1"
},
{
"_type":"product",
"_id":"2"
}
]
}
3.使用mget查詢不同id
get /zoo/product/_mget
{
"docs":[
{
"_id":"1"
},
{
"_id":"2"
}
]
}