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

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Refactor**
	- Simplified search menu logic by removing unnecessary filtering and parameters from menu item generation. No changes to visible functionality.
- **Bug Fixes**
	- Improved search index matching to retrieve all relevant entries, enhancing search accuracy.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
EYHN
2025-04-28 03:55:45 +00:00
parent e9003dec9e
commit 08d1b8dcbf
2 changed files with 4 additions and 11 deletions

View File

@@ -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')

View File

@@ -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,