feat(core): adjust search strategy (#7447)

This commit is contained in:
EYHN
2024-07-09 04:27:34 +00:00
parent 86218d87c2
commit aab9925aa1
3 changed files with 7 additions and 4 deletions

View File

@@ -299,9 +299,9 @@ export class FullTextInvertedIndex implements InvertedIndex {
async insert(trx: DataStructRWTransaction, id: number, terms: string[]) {
for (let i = 0; i < terms.length; i++) {
const tokenMap = new Map<string, Token[]>();
const term = terms[i];
const originString = terms[i];
const tokens = new GeneralTokenizer().tokenize(term);
const tokens = new GeneralTokenizer().tokenize(originString);
for (const token of tokens) {
const tokens = tokenMap.get(token.term) || [];
@@ -314,7 +314,7 @@ export class FullTextInvertedIndex implements InvertedIndex {
key: InvertedIndexKey.forString(this.fieldKey, term).buffer(),
nid: id,
pos: {
l: term.length,
l: originString.length,
i: i,
rs: tokens.map(token => [token.start, token.end]),
},

View File

@@ -36,6 +36,8 @@ export class CollectionsQuickSearchSession
keys: ['name'],
includeMatches: true,
includeScore: true,
ignoreLocation: true,
threshold: 0.0,
});
const result = fuse.search(query);

View File

@@ -151,7 +151,8 @@ export class CommandsQuickSearchSession
keys: [{ name: 'label.title', weight: 2 }, 'label.subTitle'],
includeMatches: true,
includeScore: true,
threshold: 0.4,
ignoreLocation: true,
threshold: 0.0,
});
const result = query