mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
elastic: add skip limit
This commit is contained in:
1 parent
842322d15c
commit
7457786c5c
3 files changed
+5
-2
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/elastic-search",
|
"name": "@hydrooj/elastic-search",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro",
|
"repository": "https://github.com/hydro-dev/Hydro",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
|
|||||||
@@ -32,8 +32,9 @@ bus.on('problem/del', async (domainId, docId) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
global.Hydro.lib.problemSearch = async (domainId, q, opts) => {
|
global.Hydro.lib.problemSearch = async (domainId, q, opts) => {
|
||||||
|
const allowedSize = system.get('elasic.indexSize');
|
||||||
const size = opts?.limit || system.get('pagination.problem');
|
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 union = await DomainModel.getUnion(domainId);
|
||||||
const domainIds = [domainId, ...(union?.union || [])];
|
const domainIds = [domainId, ...(union?.union || [])];
|
||||||
const res = await client.search({
|
const res = await client.search({
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
url:
|
url:
|
||||||
value: http://127.0.0.1:9200
|
value: http://127.0.0.1:9200
|
||||||
|
indexSize:
|
||||||
|
value: 10000
|
||||||
Reference in new issue
Block a user