您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
elasticSearch多获取api(批量获取_mget)
发布时间:2021-08-31 21:35:34编辑:雪饮阅读()
elasticSearch中_mget的api主要用于对文档的批量获取,至于这个获取规则则在请求正文中以doc的json数组形式传参。Doc数组决定要获取的索引、映射、id等
一个_mget的请求实例如:
请求正文:
{
"docs":[
{
"_index": "schools", "_type": "school", "_id": "1"
},
{
"_index":"schools_gov", "_type":"school", "_id": "2"
}
]
}
响应体:
{
"docs": [
{
"_index": "schools",
"_type": "school",
"_id": "1",
"_version": 6,
"_seq_no": 7,
"_primary_term": 1,
"found": true,
"_source": {
"name": "Central School4",
"description": "CBSE Affiliation",
"street": "Nagan",
"city": "paprola",
"state": "HP",
"zip": "176115",
"location": [
31.8955385,
76.8380405
],
"fees": 2004,
"tags": [
"Senior Secondary",
"beautiful campus"
],
"rating": "3.5"
}
},
{
"_index": "schools_gov",
"_type": "school",
"_id": "2",
"_version": 1,
"_seq_no": 1,
"_primary_term": 1,
"found": true,
"_source": {
"name": "City School",
"description": "ICSE",
"street": "West End",
"city": "Meerut",
"state": "UP",
"zip": "250002",
"location": [
28.9926174,
77.692485
],
"fees": 3500,
"tags": [
"fully computerized"
],
"rating": "4.5"
}
}
]
}
关键字词:elasticSearch,多获取api,批量获取,_mget