#74 - boost unmarked tags

This commit is contained in:
Simon Cambier
2023-07-22 23:04:30 +02:00
parent a7c3826a1d
commit 3ac85e7aa8
5 changed files with 18 additions and 4 deletions

View File

@@ -96,13 +96,15 @@ async function getAndMapIndexedDocument(
} }
} }
const tags = getTagsFromMetadata(metadata)
return { return {
basename: removeDiacritics(file.basename), basename: removeDiacritics(file.basename),
content, content,
path: file.path, path: file.path,
mtime: file.stat.mtime, mtime: file.stat.mtime,
tags: getTagsFromMetadata(metadata), tags: tags,
unmarkedTags: tags.map(t => t.replace('#', '')),
aliases: getAliasesFromMetadata(metadata).join(''), aliases: getAliasesFromMetadata(metadata).join(''),
headings1: metadata ? extractHeadingsFromCache(metadata, 1).join(' ') : '', headings1: metadata ? extractHeadingsFromCache(metadata, 1).join(' ') : '',
headings2: metadata ? extractHeadingsFromCache(metadata, 2).join(' ') : '', headings2: metadata ? extractHeadingsFromCache(metadata, 2).join(' ') : '',

View File

@@ -12,6 +12,7 @@
class:is-selected={selected} class:is-selected={selected}
on:mousemove on:mousemove
on:click on:click
on:keypress
on:auxclick> on:auxclick>
{#if glyph} {#if glyph}
<GlyphAddNote /> <GlyphAddNote />

View File

@@ -42,6 +42,7 @@ export type IndexedDocument = {
content: string content: string
aliases: string aliases: string
tags: string[] tags: string[]
unmarkedTags: string[]
headings1: string headings1: string
headings2: string headings2: string
headings3: string headings3: string

View File

@@ -196,6 +196,7 @@ export class Omnisearch {
headings1: settings.weightH1, headings1: settings.weightH1,
headings2: settings.weightH2, headings2: settings.weightH2,
headings3: settings.weightH3, headings3: settings.weightH3,
unmarkedTags: settings.weightUnmarkedTags
}, },
}) })
@@ -210,7 +211,6 @@ export class Omnisearch {
ext.startsWith(e.startsWith('.') ? e : '.' + e) ext.startsWith(e.startsWith('.') ? e : '.' + e)
) )
}) })
console.log(query.query.ext, results.length)
} }
// Filter query results that match the path // Filter query results that match the path

View File

@@ -7,7 +7,11 @@ import {
} from 'obsidian' } from 'obsidian'
import { writable } from 'svelte/store' import { writable } from 'svelte/store'
import { database } from './database' import { database } from './database'
import { K_DISABLE_OMNISEARCH, getTextExtractor, isCacheEnabled } from './globals' import {
K_DISABLE_OMNISEARCH,
getTextExtractor,
isCacheEnabled,
} from './globals'
import type OmnisearchPlugin from './main' import type OmnisearchPlugin from './main'
interface WeightingSettings { interface WeightingSettings {
@@ -16,6 +20,7 @@ interface WeightingSettings {
weightH1: number weightH1: number
weightH2: number weightH2: number
weightH3: number weightH3: number
weightUnmarkedTags: number
} }
export interface OmnisearchSettings extends WeightingSettings { export interface OmnisearchSettings extends WeightingSettings {
@@ -376,6 +381,10 @@ export class SettingsTab extends PluginSettingTab {
.setName(`Headings level 3 (default: ${DEFAULT_SETTINGS.weightH3})`) .setName(`Headings level 3 (default: ${DEFAULT_SETTINGS.weightH3})`)
.addSlider(cb => this.weightSlider(cb, 'weightH3')) .addSlider(cb => this.weightSlider(cb, 'weightH3'))
new Setting(containerEl)
.setName(`Tags without the # (default: ${DEFAULT_SETTINGS.weightUnmarkedTags})`)
.addSlider(cb => this.weightSlider(cb, 'weightUnmarkedTags'))
//#endregion Results Weighting //#endregion Results Weighting
//#region Debugging //#region Debugging
@@ -473,6 +482,7 @@ export const DEFAULT_SETTINGS: OmnisearchSettings = {
weightH1: 1.5, weightH1: 1.5,
weightH2: 1.3, weightH2: 1.3,
weightH3: 1.1, weightH3: 1.1,
weightUnmarkedTags: 1.1,
welcomeMessage: '', welcomeMessage: '',
verboseLogging: false, verboseLogging: false,
@@ -491,4 +501,4 @@ export async function saveSettings(plugin: Plugin): Promise<void> {
export function isPluginDisabled(): boolean { export function isPluginDisabled(): boolean {
return app.loadLocalStorage(K_DISABLE_OMNISEARCH) == '1' return app.loadLocalStorage(K_DISABLE_OMNISEARCH) == '1'
} }