Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

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

EYHNaab9925aa195
diff --git a/packages/common/infra/src/sync/indexer/impl/indexeddb/inverted-index.ts b/packages/common/infra/src/sync/indexer/impl/indexeddb/inverted-index.ts
index 88f5373304..76f85d4d6f 100644
--- a/packages/common/infra/src/sync/indexer/impl/indexeddb/inverted-index.ts
+++ b/packages/common/infra/src/sync/indexer/impl/indexeddb/inverted-index.ts
@@ -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]),
},
diff --git a/packages/frontend/core/src/modules/quicksearch/impls/collections.ts b/packages/frontend/core/src/modules/quicksearch/impls/collections.ts
index 7837276f82..11fdb21c51 100644
--- a/packages/frontend/core/src/modules/quicksearch/impls/collections.ts
+++ b/packages/frontend/core/src/modules/quicksearch/impls/collections.ts
@@ -36,6 +36,8 @@ export class CollectionsQuickSearchSession
keys: ['name'],
includeMatches: true,
includeScore: true,
+ ignoreLocation: true,
+ threshold: 0.0,
});
const result = fuse.search(query);
diff --git a/packages/frontend/core/src/modules/quicksearch/impls/commands.ts b/packages/frontend/core/src/modules/quicksearch/impls/commands.ts
index dd07759c71..e1924567b7 100644
--- a/packages/frontend/core/src/modules/quicksearch/impls/commands.ts
+++ b/packages/frontend/core/src/modules/quicksearch/impls/commands.ts
@@ -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