fix(core): should use doc index for at menu config (#9430)

This commit is contained in:
pengx17
2024-12-31 09:31:07 +00:00
parent e3d681306c
commit 1c6c2194c4

View File

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