优化中文搜索

This commit is contained in:
undefined committed 2020-09-06 12:12:54 +08:00
1 parent f2f0212947
commit 6eed519407
11 files changed
+91 -9

No files matched your search

+2 -1
View File
@@ -1,3 +1,4 @@
import { inspect } from 'util';
import * as judge from './judge';
import { ValidationError } from '../error';
import * as check from '../check';
@@ -108,7 +109,7 @@ class SystemScriptHandler extends SystemHandler {
domainId,
rid,
status: STATUS.STATUS_ACCEPTED,
message: ret.toString(),
message: inspect(ret, false, 10, true),
judger: 1,
time,
memory: 0,
+4 -3
View File
@@ -61,10 +61,11 @@ export function get(domainId: string, docType: number, docId: DocID) {
return coll.findOne({ domainId, docType, docId });
}
export async function set(domainId: string, docType: number, docId: DocID, args: any) {
export async function set(domainId: string, docType: number, docId: DocID, $set: any) {
await bus.parallel('document/set', domainId, docType, docId, $set);
const res = await coll.findOneAndUpdate(
{ domainId, docType, docId },
{ $set: args },
{ $set },
{ returnOriginal: false, upsert: true },
);
return res.value;
@@ -339,7 +340,7 @@ async function ensureIndexes() {
await ic({ domainId: 1, docType: 1, docId: 1 }, u);
await ic({ domainId: 1, docType: 1, owner: 1, docId: -1 });
// For problem
await ic({ domainId: 1, docType: 1, title: 'text' }, s);
await ic({ domainId: 1, docType: 1, search: 'text', title: 'text' }, s);
await ic({ domainId: 1, docType: 1, category: 1, docId: 1 }, s);
await ic({ domainId: 1, docType: 1, hidden: 1, category: 1, docId: 1 }, s);
await ic({ domainId: 1, docType: 1, tag: 1, docId: 1 }, s);
+3 -2
View File
@@ -1,6 +1,6 @@
/* eslint-disable no-await-in-loop */
import cluster from 'cluster';
import { Db } from 'mongodb';
import { Db, ObjectID } from 'mongodb';
import { Mdoc, Rdoc, User } from '../interface';
const _hooks: Record<keyof any, Array<(...args: any[]) => any>> = {};
@@ -21,7 +21,8 @@ interface EventMap {
'user/message': (uid: number, mdoc: Mdoc, udoc: User) => void
'document/add': (doc: any) => string | void
'document/add': (doc: any) => Promise<string | void> | string | void
'document/set': (domainId: string, docType: number, docId: ObjectID | string | number, args: any) => Promise<string | void> | string | void
'record/change': (rdoc: Rdoc, $set?: any, $push?: any) => void
}