elastic: add skip limit

This commit is contained in:
undefined committed 2022-05-13 13:14:44 +08:00
1 parent 842322d15c
commit 7457786c5c
3 files changed
+5 -2

No files matched your search

+2 -1
View File
@@ -32,8 +32,9 @@ bus.on('problem/del', async (domainId, docId) => {
});
global.Hydro.lib.problemSearch = async (domainId, q, opts) => {
const allowedSize = system.get('elasic.indexSize');
const size = opts?.limit || system.get('pagination.problem');
const from = opts?.skip || 0;
const from = Math.min(allowedSize - size, opts?.skip || 0);
const union = await DomainModel.getUnion(domainId);
const domainIds = [domainId, ...(union?.union || [])];
const res = await client.search({