Separate H4 and colon heading boosts
This commit is contained in:
@@ -64,6 +64,8 @@ export type IndexedDocument = {
|
|||||||
headings1: string
|
headings1: string
|
||||||
headings2: string
|
headings2: string
|
||||||
headings3: string
|
headings3: string
|
||||||
|
headings4: string
|
||||||
|
colonHeadings: string
|
||||||
|
|
||||||
// TODO: reimplement this
|
// TODO: reimplement this
|
||||||
doesNotExist?: boolean
|
doesNotExist?: boolean
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ export class NotesIndexer {
|
|||||||
headings1: '',
|
headings1: '',
|
||||||
headings2: '',
|
headings2: '',
|
||||||
headings3: '',
|
headings3: '',
|
||||||
|
headings4: '',
|
||||||
|
colonHeadings: '',
|
||||||
|
|
||||||
doesNotExist: true,
|
doesNotExist: true,
|
||||||
parent,
|
parent,
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ export class DocumentsRepository {
|
|||||||
const headings1 = metadata ? extractHeadingsFromCache(metadata, 1) : []
|
const headings1 = metadata ? extractHeadingsFromCache(metadata, 1) : []
|
||||||
const headings2 = metadata ? extractHeadingsFromCache(metadata, 2) : []
|
const headings2 = metadata ? extractHeadingsFromCache(metadata, 2) : []
|
||||||
const headings3 = metadata ? extractHeadingsFromCache(metadata, 3) : []
|
const headings3 = metadata ? extractHeadingsFromCache(metadata, 3) : []
|
||||||
|
const headings4 = metadata ? extractHeadingsFromCache(metadata, 4) : []
|
||||||
|
|
||||||
const akaHeadings: string[] = content
|
const akaHeadings: string[] = content
|
||||||
.split(/\n\s*\n/)[0]
|
.split(/\n\s*\n/)[0]
|
||||||
@@ -271,7 +272,9 @@ export class DocumentsRepository {
|
|||||||
aliases: getAliasesFromMetadata(metadata).join(''),
|
aliases: getAliasesFromMetadata(metadata).join(''),
|
||||||
headings1: [...headings1, ...akaHeadings].join(' '),
|
headings1: [...headings1, ...akaHeadings].join(' '),
|
||||||
headings2: headings2.join(' '),
|
headings2: headings2.join(' '),
|
||||||
headings3: [...headings3, ...colonHeadings].join(' '),
|
headings3: headings3.join(' '),
|
||||||
|
headings4: headings4.join(' '),
|
||||||
|
colonHeadings: colonHeadings.join(' '),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,6 +180,8 @@ export class SearchEngine {
|
|||||||
headings1: settings.weightH1,
|
headings1: settings.weightH1,
|
||||||
headings2: settings.weightH2,
|
headings2: settings.weightH2,
|
||||||
headings3: settings.weightH3,
|
headings3: settings.weightH3,
|
||||||
|
headings4: settings.weightH4,
|
||||||
|
colonHeadings: settings.weightColonHeadings,
|
||||||
tags: settings.weightUnmarkedTags,
|
tags: settings.weightUnmarkedTags,
|
||||||
unmarkedTags: settings.weightUnmarkedTags,
|
unmarkedTags: settings.weightUnmarkedTags,
|
||||||
},
|
},
|
||||||
@@ -601,6 +603,8 @@ export class SearchEngine {
|
|||||||
'headings1',
|
'headings1',
|
||||||
'headings2',
|
'headings2',
|
||||||
'headings3',
|
'headings3',
|
||||||
|
'headings4',
|
||||||
|
'colonHeadings',
|
||||||
],
|
],
|
||||||
storeFields: ['tags', 'mtime'],
|
storeFields: ['tags', 'mtime'],
|
||||||
logger(_level, _message, code) {
|
logger(_level, _message, code) {
|
||||||
|
|||||||
@@ -129,6 +129,8 @@ export function getDefaultSettings(app: App): OmnisearchSettings {
|
|||||||
weightH1: 6,
|
weightH1: 6,
|
||||||
weightH2: 5,
|
weightH2: 5,
|
||||||
weightH3: 4,
|
weightH3: 4,
|
||||||
|
weightH4: 3,
|
||||||
|
weightColonHeadings: 2,
|
||||||
weightUnmarkedTags: 2,
|
weightUnmarkedTags: 2,
|
||||||
weightCustomProperties: [] as { name: string; weight: number }[],
|
weightCustomProperties: [] as { name: string; weight: number }[],
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,14 @@ export function injectSettingsWeighting(
|
|||||||
.setName(`Headings level 3 (default: ${defaultSettings.weightH3})`)
|
.setName(`Headings level 3 (default: ${defaultSettings.weightH3})`)
|
||||||
.addSlider(cb => weightSlider(cb, 'weightH3'))
|
.addSlider(cb => weightSlider(cb, 'weightH3'))
|
||||||
|
|
||||||
|
new Setting(containerEl)
|
||||||
|
.setName(`Headings level 4 (default: ${defaultSettings.weightH4})`)
|
||||||
|
.addSlider(cb => weightSlider(cb, 'weightH4'))
|
||||||
|
|
||||||
|
new Setting(containerEl)
|
||||||
|
.setName(`Colon headings (default: ${defaultSettings.weightColonHeadings})`)
|
||||||
|
.addSlider(cb => weightSlider(cb, 'weightColonHeadings'))
|
||||||
|
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName(`Tags (default: ${defaultSettings.weightUnmarkedTags})`)
|
.setName(`Tags (default: ${defaultSettings.weightUnmarkedTags})`)
|
||||||
.addSlider(cb => weightSlider(cb, 'weightUnmarkedTags'))
|
.addSlider(cb => weightSlider(cb, 'weightUnmarkedTags'))
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ export interface WeightingSettings {
|
|||||||
weightH1: number
|
weightH1: number
|
||||||
weightH2: number
|
weightH2: number
|
||||||
weightH3: number
|
weightH3: number
|
||||||
|
weightH4: number
|
||||||
|
weightColonHeadings: number
|
||||||
weightUnmarkedTags: number
|
weightUnmarkedTags: number
|
||||||
}
|
}
|
||||||
export function isPluginDisabled(app: App): boolean {
|
export function isPluginDisabled(app: App): boolean {
|
||||||
|
|||||||
@@ -132,13 +132,16 @@ describe('indexed heading metadata', () => {
|
|||||||
expect(headings.headings1).toBe('H1 Heading')
|
expect(headings.headings1).toBe('H1 Heading')
|
||||||
expect(headings.headings2).toBe('H2 Heading')
|
expect(headings.headings2).toBe('H2 Heading')
|
||||||
expect(headings.headings3).toBe('H3 Heading')
|
expect(headings.headings3).toBe('H3 Heading')
|
||||||
|
expect(headings.headings4).toBe('H4 Heading')
|
||||||
|
|
||||||
const fork = await getDocument('tests/notes/fork-features.md')
|
const fork = await getDocument('tests/notes/fork-features.md')
|
||||||
expect(fork.headings1).toBe('Packing List')
|
expect(fork.headings1).toBe('Packing List')
|
||||||
expect(fork.headings3).toBe('Japan trip')
|
expect(fork.headings3).toBe('')
|
||||||
|
expect(fork.colonHeadings).toBe('Japan trip')
|
||||||
|
|
||||||
const colon = await getDocument('tests/notes/colon-variants.md')
|
const colon = await getDocument('tests/notes/colon-variants.md')
|
||||||
expect(colon.headings3).toBe('Colon heading')
|
expect(colon.headings3).toBe('')
|
||||||
|
expect(colon.colonHeadings).toBe('Colon heading')
|
||||||
|
|
||||||
const aka = await getDocument('tests/notes/aka-variants.md')
|
const aka = await getDocument('tests/notes/aka-variants.md')
|
||||||
expect(aka.headings1).toBe('lowercase alias')
|
expect(aka.headings1).toBe('lowercase alias')
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ type Note = { path: string; basename: string; text: string }
|
|||||||
|
|
||||||
const defaults: any = {
|
const defaults: any = {
|
||||||
fuzziness: '1', weightBasename: 10, weightDirectory: 7, weightH1: 6,
|
fuzziness: '1', weightBasename: 10, weightDirectory: 7, weightH1: 6,
|
||||||
weightH2: 5, weightH3: 4, weightUnmarkedTags: 2, recencyBoost: '0',
|
weightH2: 5, weightH3: 4, weightH4: 3, weightColonHeadings: 2, weightUnmarkedTags: 2, recencyBoost: '0',
|
||||||
downrankedFoldersFilters: [], hideExcluded: false, weightCustomProperties: [],
|
downrankedFoldersFilters: [], hideExcluded: false, weightCustomProperties: [],
|
||||||
ignoreDiacritics: true, ignoreArabicDiacritics: false, simpleSearch: false,
|
ignoreDiacritics: true, ignoreArabicDiacritics: false, simpleSearch: false,
|
||||||
maxEmbeds: 5, renderLineReturnInExcerpts: true, highlight: true,
|
maxEmbeds: 5, renderLineReturnInExcerpts: true, highlight: true,
|
||||||
@@ -36,7 +36,7 @@ function indexDocument(note: Note): IndexedDocument {
|
|||||||
path: note.path, basename: note.basename, displayTitle: '', mtime: 1,
|
path: note.path, basename: note.basename, displayTitle: '', mtime: 1,
|
||||||
content: note.text, cleanedContent: note.text, aliases: '', tags: [],
|
content: note.text, cleanedContent: note.text, aliases: '', tags: [],
|
||||||
unmarkedTags: [], headings1: headings1.join(' '), headings2: headings2.join(' '),
|
unmarkedTags: [], headings1: headings1.join(' '), headings2: headings2.join(' '),
|
||||||
headings3: headings3.join(' '),
|
headings3: headings3.join(' '), headings4: '', colonHeadings: '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user