core&ui&elastic: support elastic search and allow search result pagination

This commit is contained in:
undefined committed 2022-03-18 22:48:23 +08:00
1 parent ea6529b523
commit 18fc66ecb7
33 files changed
+411 -244

No files matched your search

+7 -2
View File
@@ -46,8 +46,13 @@ bus.on('problem/del', async (domainId, docId) => {
await Promise.all(tasks);
});
global.Hydro.lib.problemSearch = async (domainId: string, query: string, limit = system.get('pagination.problem')) => {
global.Hydro.lib.problemSearch = async (domainId, query, opts) => {
const limit = opts?.limit || system.get('pagination.problem');
const ids = await sonic.query('problem', `${domainId}@title`, query, { limit });
if (limit - ids.length > 0) ids.push(...await sonic.query('problem', `${domainId}@content`, query, { limit: limit - ids.length }));
return ids;
return {
countRelation: ids.length >= limit ? 'gte' : 'eq',
total: ids.length,
hits: ids,
};
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/sonic",
"version": "1.2.4",
"version": "1.2.5",
"description": "Sonic search service",
"main": "service.js",
"typings": "service.d.ts",