mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core&ui&elastic: support elastic search and allow search result pagination
This commit is contained in:
1 parent
ea6529b523
commit
18fc66ecb7
33 files changed
+411
-244
No files matched your search
@@ -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,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",
|
||||
|
||||
Reference in new issue
Block a user