同一索引中多种类型的 Elasticsearch 分页
Elasticsearch pagination on multiple types in same index
在单个索引中搜索多种类型时,我正在尝试为多种类型设置分页。我可以为总记录设置分页,但我的标准是为 2 种不同类型设置分页。有人可以建议吗?
要求:-
GET /testindex/txnentity,sampletxn/_search?pretty=true
{
"query": {
"bool": {
"must": [
{
"query_string": {
"fields": [
"_all"
],
"query": "Tester*"
}
}
]
}
},
"from": 0,
"size": 30
}
用例:-
txnentity --> pagination for 5 records
sampletxn --> pagination for 10 records
在单个查询中查询多个类型时,无法按类型分隔分页。如果你想这样做,你需要发送一个包含两个查询的 multi-search query,每个查询对应一种类型并带有适当的分页:
POST testindex/_msearch
{"type" : "txnentity"}
{"size": 5, "query": {"bool": {"must": [{"query_string": {"fields": ["_all"],"query": "Tester*"}}]}}}
{"type" : "sampletxn"}
{"size": 10, "query": {"bool": {"must": [{"query_string": {"fields": ["_all"],"query": "Tester*"}}]}}}
在单个索引中搜索多种类型时,我正在尝试为多种类型设置分页。我可以为总记录设置分页,但我的标准是为 2 种不同类型设置分页。有人可以建议吗?
要求:-
GET /testindex/txnentity,sampletxn/_search?pretty=true
{
"query": {
"bool": {
"must": [
{
"query_string": {
"fields": [
"_all"
],
"query": "Tester*"
}
}
]
}
},
"from": 0,
"size": 30
}
用例:-
txnentity --> pagination for 5 records
sampletxn --> pagination for 10 records
在单个查询中查询多个类型时,无法按类型分隔分页。如果你想这样做,你需要发送一个包含两个查询的 multi-search query,每个查询对应一种类型并带有适当的分页:
POST testindex/_msearch
{"type" : "txnentity"}
{"size": 5, "query": {"bool": {"must": [{"query_string": {"fields": ["_all"],"query": "Tester*"}}]}}}
{"type" : "sampletxn"}
{"size": 10, "query": {"bool": {"must": [{"query_string": {"fields": ["_all"],"query": "Tester*"}}]}}}