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): should use doc index for at menu config (#9430)

pengx171c6c2194c4a7
diff --git a/packages/frontend/core/src/modules/at-menu-config/services/index.ts b/packages/frontend/core/src/modules/at-menu-config/services/index.ts
index 7b2314e439..8b600a58e8 100644
--- a/packages/frontend/core/src/modules/at-menu-config/services/index.ts
+++ b/packages/frontend/core/src/modules/at-menu-config/services/index.ts
@@ -429,7 +429,7 @@ export class AtMenuConfigService extends Service {
// only search docs by title, excluding blocks
private searchDocs$(query: string) {
- return this.docsSearch.indexer.blockIndex
+ return this.docsSearch.indexer.docIndex
.aggregate$(
{
type: 'boolean',
@@ -437,32 +437,21 @@ export class AtMenuConfigService extends Service {
queries: [
{
type: 'match',
- field: 'content',
+ field: 'title',
match: query,
},
- {
- type: 'boolean',
- occur: 'should',
- queries: [
- {
- type: 'match',
- field: 'flavour',
- match: 'affine:page',
- },
- ],
- },
],
},
'docId',
{
hits: {
- fields: ['docId', 'content'],
+ fields: ['docId', 'title'],
pagination: {
limit: 1,
},
highlights: [
{
- field: 'content',
+ field: 'title',
before: `<span style="color: ${cssVarV2('text/emphasis')}">`,
end: '</span>',
},
@@ -475,8 +464,8 @@ export class AtMenuConfigService extends Service {
buckets.map(bucket => {
return {
id: bucket.key,
- title: bucket.hits.nodes[0].fields.content,
- highlights: bucket.hits.nodes[0].highlights.content[0],
+ title: bucket.hits.nodes[0].fields.title,
+ highlights: bucket.hits.nodes[0].highlights.title[0],
};
})
)