diff --git a/src/search/omnisearch.ts b/src/search/omnisearch.ts index 53b5746..fbe3f0f 100644 --- a/src/search/omnisearch.ts +++ b/src/search/omnisearch.ts @@ -31,11 +31,22 @@ const tokenize = (text: string): string[] => { export class Omnisearch { public static readonly options: Options = { tokenize, + extractField: (doc, fieldName) => { + if (fieldName === 'folder') { + // return path without the filename + const parts = doc.path.split('/') + parts.pop() + return parts.join('/') + } + return (doc as any)[fieldName] + }, processTerm: (term: string) => (settings.ignoreDiacritics ? removeDiacritics(term) : term).toLowerCase(), idField: 'path', fields: [ 'basename', + // Different from `path`, since `path` is the unique index and needs to include the filename + 'folder', 'aliases', 'content', 'headings1',