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