core: allow searching tags

This commit is contained in:
undefined committed 2023-05-12 10:54:19 +08:00
1 parent cfb6accffa
commit 00542e067f
1 file changed
+2 -2
+2 -2
View File
@@ -114,8 +114,8 @@ function buildQuery(udoc: User) {
const defaultSearch = async (domainId: string, q: string, options?: ProblemSearchOptions) => {
const escaped = escapeRegExp(q.toLowerCase());
const $regex = new RegExp(q.length >= 3 ? escaped : `\\A${escaped}`, 'gmi');
const filter = { $or: [{ pid: { $regex } }, { title: { $regex } }] };
const $regex = new RegExp(q.length >= 2 ? escaped : `\\A${escaped}`, 'gmi');
const filter = { $or: [{ pid: { $regex } }, { title: { $regex } }, { tag: q }] };
const pdocs = await problem.getMulti(domainId, filter, ['domainId', 'docId', 'pid'])
.skip(options.skip || 0).limit(options.limit || system.get('pagination.problem')).toArray();
if (!Number.isNaN(+q)) {