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
@@ -227,10 +227,10 @@ export class FullTextInvertedIndex implements InvertedIndex {
const key = InvertedIndexKey.forString(this.fieldKey, token.term); const key = InvertedIndexKey.forString(this.fieldKey, token.term);
const objs = [ const objs = [
// match exact // match exact
await trx ...(await trx
.objectStore('invertedIndex') .objectStore('invertedIndex')
.index('key') .index('key')
.get([this.table, key.buffer()]), .getAll([this.table, key.buffer()])),
// match prefix // match prefix
...(await trx ...(await trx
.objectStore('invertedIndex') .objectStore('invertedIndex')
@@ -2,7 +2,6 @@ import type {
CollectionMeta, CollectionMeta,
TagMeta, TagMeta,
} from '@affine/core/components/page-list'; } from '@affine/core/components/page-list';
import { fuzzyMatch } from '@affine/core/utils/fuzzy-match';
import { I18n } from '@affine/i18n'; import { I18n } from '@affine/i18n';
import { createSignalFromObservable } from '@blocksuite/affine/shared/utils'; import { createSignalFromObservable } from '@blocksuite/affine/shared/utils';
import type { DocMeta } from '@blocksuite/affine/store'; import type { DocMeta } from '@blocksuite/affine/store';
@@ -108,8 +107,7 @@ export class SearchMenuService extends Service {
...meta, ...meta,
highlights, highlights,
}, },
action, action
query
); );
}) })
.filter(m => !!m); .filter(m => !!m);
@@ -184,8 +182,7 @@ export class SearchMenuService extends Service {
private toDocMenuItem( private toDocMenuItem(
meta: DocMetaWithHighlights, meta: DocMetaWithHighlights,
action: SearchDocMenuAction, action: SearchDocMenuAction
query?: string
): LinkedMenuItem | null { ): LinkedMenuItem | null {
const title = this.docDisplayMetaService.title$(meta.id, { const title = this.docDisplayMetaService.title$(meta.id, {
reference: true, reference: true,
@@ -195,10 +192,6 @@ export class SearchMenuService extends Service {
return null; return null;
} }
if (query && !fuzzyMatch(title, query)) {
return null;
}
return { return {
name: meta.highlights ? html`${unsafeHTML(meta.highlights)}` : title, name: meta.highlights ? html`${unsafeHTML(meta.highlights)}` : title,
key: meta.id, key: meta.id,