mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
feat(core): adjust search strategy (#7447)
This commit is contained in:
@@ -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]),
|
||||
},
|
||||
|
||||
@@ -36,6 +36,8 @@ export class CollectionsQuickSearchSession
|
||||
keys: ['name'],
|
||||
includeMatches: true,
|
||||
includeScore: true,
|
||||
ignoreLocation: true,
|
||||
threshold: 0.0,
|
||||
});
|
||||
|
||||
const result = fuse.search(query);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user