#196 - Added customizable weighting for note's directory
This commit is contained in:
@@ -32,7 +32,7 @@ export class Omnisearch {
|
||||
public static readonly options: Options<IndexedDocument> = {
|
||||
tokenize,
|
||||
extractField: (doc, fieldName) => {
|
||||
if (fieldName === 'folder') {
|
||||
if (fieldName === 'directory') {
|
||||
// return path without the filename
|
||||
const parts = doc.path.split('/')
|
||||
parts.pop()
|
||||
@@ -46,7 +46,7 @@ export class Omnisearch {
|
||||
fields: [
|
||||
'basename',
|
||||
// Different from `path`, since `path` is the unique index and needs to include the filename
|
||||
'folder',
|
||||
'directory',
|
||||
'aliases',
|
||||
'content',
|
||||
'headings1',
|
||||
@@ -179,6 +179,7 @@ export class Omnisearch {
|
||||
combineWith: 'AND',
|
||||
boost: {
|
||||
basename: settings.weightBasename,
|
||||
directory: settings.weightDirectory,
|
||||
aliases: settings.weightBasename,
|
||||
headings1: settings.weightH1,
|
||||
headings2: settings.weightH2,
|
||||
|
||||
@@ -12,6 +12,7 @@ import type OmnisearchPlugin from './main'
|
||||
|
||||
interface WeightingSettings {
|
||||
weightBasename: number
|
||||
weightDirectory: number
|
||||
weightH1: number
|
||||
weightH2: number
|
||||
weightH3: number
|
||||
@@ -318,6 +319,10 @@ export class SettingsTab extends PluginSettingTab {
|
||||
)
|
||||
.addSlider(cb => this.weightSlider(cb, 'weightBasename'))
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(`File directory (default: ${DEFAULT_SETTINGS.weightDirectory})`)
|
||||
.addSlider(cb => this.weightSlider(cb, 'weightDirectory'))
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(`Headings level 1 (default: ${DEFAULT_SETTINGS.weightH1})`)
|
||||
.addSlider(cb => this.weightSlider(cb, 'weightH1'))
|
||||
@@ -383,7 +388,8 @@ export const DEFAULT_SETTINGS: OmnisearchSettings = {
|
||||
showPreviousQueryResults: true,
|
||||
simpleSearch: false,
|
||||
|
||||
weightBasename: 2,
|
||||
weightBasename: 3,
|
||||
weightDirectory: 2,
|
||||
weightH1: 1.5,
|
||||
weightH2: 1.3,
|
||||
weightH3: 1.1,
|
||||
|
||||
Reference in New Issue
Block a user