[英]How to do pagination (from, size) with elastic search aggregation query in nodejs
我目前有一個 API 將用戶使用日志返回到前端,但數據太大,所以我需要分頁。 我無法在彈性搜索聚合查詢中進行分頁。 目前使用此代碼
const result = await esClient.search({
index: 'user-logs',
body: {
size: 0,
query: {
bool: {
filter: [
{
range: {
timestamp: {
gte: 1596804771643,
lte: 1596904771643,
format: 'epoch_millis'
}
}
},
{
query_string: {
analyze_wildcard: true,
query: `*`
}
}
]
}
},
aggs: {
3: {
terms: {
field: 'email.keyword',
size: 10,
order: {
_term: 'desc'
},
min_doc_count: 1
},
aggs: {
4: {
terms: {
field: 'mobile.keyword',
order: {
_term: 'desc'
},
min_doc_count: 1
},
aggs: {
5: {
terms: {
field: 'fullName.keyword',
order: {
_term: 'desc'
},
min_doc_count: 1
},
aggs: {
6: {
terms: {
field: 'branchName.keyword',
order: {
_term: 'desc'
},
min_doc_count: 1
},
aggs: {
1: {
sum: {
field: 'timespent'
}
}
}
}
}
}
}
}
}
}
}
}
});
在簡單查詢中,我使用“from”和“size”,但在聚合查詢的情況下,它們不起作用。 我是彈性搜索的新手。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.