better-search: use cutForSearch

This commit is contained in:
undefined committed 2020-09-06 15:28:45 +08:00
1 parent f75c12f4bd
commit dbc5fff09f
3 files changed
+4 -4

No files matched your search

+2 -2
View File
@@ -12,12 +12,12 @@ declare module 'hydrooj' {
bus.on('document/add', async (doc) => {
if (doc.type !== document.TYPE_PROBLEM) return;
const pdoc = doc as Pdoc;
const segments = nodejieba.cut(pdoc.title);
const segments = nodejieba.cutForSearch(pdoc.title);
pdoc.search = segments.join(' ');
});
bus.on('document/set', async (domainId, docType, docId, $set) => {
if (docType !== document.TYPE_PROBLEM || !$set.title) return;
const segments = nodejieba.cut($set.title);
const segments = nodejieba.cutForSearch($set.title);
$set.search = segments.join(' ');
});
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/better-search",
"version": "1.0.1",
"version": "1.0.2",
"description": "Enhance Problem Search",
"main": "package.json",
"repository": "https://github.com/hydro-dev/Hydro.git",
+1 -1
View File
@@ -6,7 +6,7 @@ export const description = 'Ensure index for peoblem search';
export async function run() {
await document.coll.find({ docType: document.TYPE_PROBLEM }).forEach(async (doc: Pdoc) => {
const segments = nodejieba.cut(doc.title);
const segments = nodejieba.cutForSearch(doc.title);
await document.coll.updateOne({ _id: doc._id }, { $set: { search: segments.join(' ') } });
});
}