Skip to content

Commit

Permalink
fix(core): should use doc index for at menu config (#9430)
Browse files Browse the repository at this point in the history
  • Loading branch information
pengx17 committed Dec 31, 2024
1 parent e3d6813 commit 1c6c219
Showing 1 changed file with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,40 +429,29 @@ 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',
occur: 'must',
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>',
},
Expand All @@ -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],
};
})
)
Expand Down

0 comments on commit 1c6c219

Please sign in to comment.