diff --git a/src/search.ts b/src/search.ts index c009e36..4c82a4b 100644 --- a/src/search.ts +++ b/src/search.ts @@ -76,6 +76,13 @@ async function search(query: Query): Promise { }, }) + // Half the score for files that are in Obsidian's excluded list + results.forEach(result => { + if (app.metadataCache.isUserIgnored(result.id)) { + result.score /= 3 // TODO: make this value configurable or toggleable? + } + }) + // If the search query contains quotes, filter out results that don't have the exact match const exactTerms = query.getExactTerms() if (exactTerms.length) { @@ -183,7 +190,6 @@ export async function addToIndex(file: TAbstractFile): Promise { try { // console.log(`Omnisearch - adding ${file.path} to index`) const fileCache = app.metadataCache.getFileCache(file) - // console.log(fileCache) if (indexedNotes[file.path]) { throw new Error(`${file.basename} is already indexed`) diff --git a/src/types.d.ts b/src/types.d.ts new file mode 100644 index 0000000..a46c2d6 --- /dev/null +++ b/src/types.d.ts @@ -0,0 +1,7 @@ +import { type MetadataCache } from 'obsidian' + +declare module 'obsidian' { + interface MetadataCache { + isUserIgnored(path:string):boolean + } +}