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.

fix(core): better search result (#12015)

EYHN08d1b8dcbf5a
diff --git a/packages/common/nbstore/src/impls/idb/indexer/inverted-index.ts b/packages/common/nbstore/src/impls/idb/indexer/inverted-index.ts
index 2fc61ed712..09ec637cd1 100644
--- a/packages/common/nbstore/src/impls/idb/indexer/inverted-index.ts
+++ b/packages/common/nbstore/src/impls/idb/indexer/inverted-index.ts
@@ -227,10 +227,10 @@ export class FullTextInvertedIndex implements InvertedIndex {
const key = InvertedIndexKey.forString(this.fieldKey, token.term);
const objs = [
// match exact
- await trx
+ ...(await trx
.objectStore('invertedIndex')
.index('key')
- .get([this.table, key.buffer()]),
+ .getAll([this.table, key.buffer()])),
// match prefix
...(await trx
.objectStore('invertedIndex')
diff --git a/packages/frontend/core/src/modules/search-menu/services/index.ts b/packages/frontend/core/src/modules/search-menu/services/index.ts
index 766bf9a843..4f315a0d83 100644
--- a/packages/frontend/core/src/modules/search-menu/services/index.ts
+++ b/packages/frontend/core/src/modules/search-menu/services/index.ts
@@ -2,7 +2,6 @@ import type {
CollectionMeta,
TagMeta,
} from '@affine/core/components/page-list';
-import { fuzzyMatch } from '@affine/core/utils/fuzzy-match';
import { I18n } from '@affine/i18n';
import { createSignalFromObservable } from '@blocksuite/affine/shared/utils';
import type { DocMeta } from '@blocksuite/affine/store';
@@ -108,8 +107,7 @@ export class SearchMenuService extends Service {
...meta,
highlights,
},
- action,
- query
+ action
);
})
.filter(m => !!m);
@@ -184,8 +182,7 @@ export class SearchMenuService extends Service {
private toDocMenuItem(
meta: DocMetaWithHighlights,
- action: SearchDocMenuAction,
- query?: string
+ action: SearchDocMenuAction
): LinkedMenuItem | null {
const title = this.docDisplayMetaService.title$(meta.id, {
reference: true,
@@ -195,10 +192,6 @@ export class SearchMenuService extends Service {
return null;
}
- if (query && !fuzzyMatch(title, query)) {
- return null;
- }
-
return {
name: meta.highlights ? html`${unsafeHTML(meta.highlights)}` : title,
key: meta.id,