mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
优化中文搜索
This commit is contained in:
1 parent
f2f0212947
commit
6eed519407
11 files changed
+91
-9
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user