#196 - Index the path
This commit is contained in:
@@ -31,11 +31,22 @@ const tokenize = (text: string): string[] => {
|
|||||||
export class Omnisearch {
|
export class Omnisearch {
|
||||||
public static readonly options: Options<IndexedDocument> = {
|
public static readonly options: Options<IndexedDocument> = {
|
||||||
tokenize,
|
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) =>
|
processTerm: (term: string) =>
|
||||||
(settings.ignoreDiacritics ? removeDiacritics(term) : term).toLowerCase(),
|
(settings.ignoreDiacritics ? removeDiacritics(term) : term).toLowerCase(),
|
||||||
idField: 'path',
|
idField: 'path',
|
||||||
fields: [
|
fields: [
|
||||||
'basename',
|
'basename',
|
||||||
|
// Different from `path`, since `path` is the unique index and needs to include the filename
|
||||||
|
'folder',
|
||||||
'aliases',
|
'aliases',
|
||||||
'content',
|
'content',
|
||||||
'headings1',
|
'headings1',
|
||||||
|
|||||||
Reference in New Issue
Block a user