feat:Chinese search is supported

This commit is contained in:
zedgan 2023-08-09 10:04:36 +08:00
parent d6eac394cf
commit 34c288de76
2 changed files with 2 additions and 5 deletions

View File

@ -1216,7 +1216,7 @@ components:
x-webhooks: x-webhooks:
newPet: newPet:
post: post:
summary: New pet summary: New pet 中文测试
description: Information about a new pet in the systems description: Information about a new pet in the systems
operationId: newPet operationId: newPet
tags: tags:

View File

@ -28,8 +28,6 @@ function initEmpty() {
builder.field('description'); builder.field('description');
builder.ref('ref'); builder.ref('ref');
builder.pipeline.add(lunr.trimmer, lunr.stopWordFilter, lunr.stemmer);
index = new Promise(resolve => { index = new Promise(resolve => {
resolveIndex = resolve; resolveIndex = resolve;
}); });
@ -38,8 +36,7 @@ function initEmpty() {
initEmpty(); initEmpty();
const expandTerm = term => { const expandTerm = term => {
const token = lunr.trimmer(new lunr.Token(term, {})); return `*${term}*`;
return '*' + lunr.stemmer(token) + '*';
}; };
export function add<T>(title: string, description: string, meta?: T) { export function add<T>(title: string, description: string, meta?: T) {