Fixed bug with diacritcs and quoted searches
Also added more cached data
This commit is contained in:
@@ -17,6 +17,8 @@ import {
|
|||||||
isFilenameIndexable,
|
isFilenameIndexable,
|
||||||
logDebug,
|
logDebug,
|
||||||
makeMD5,
|
makeMD5,
|
||||||
|
removeDiacritics,
|
||||||
|
stripMarkdownCharacters,
|
||||||
} from './tools/utils'
|
} from './tools/utils'
|
||||||
import type { CanvasData } from 'obsidian/canvas'
|
import type { CanvasData } from 'obsidian/canvas'
|
||||||
import type { AsPlainObject } from 'minisearch'
|
import type { AsPlainObject } from 'minisearch'
|
||||||
@@ -143,6 +145,8 @@ async function getAndMapIndexedDocument(
|
|||||||
return {
|
return {
|
||||||
basename: file.basename,
|
basename: file.basename,
|
||||||
content,
|
content,
|
||||||
|
/** Content without diacritics and markdown chars */
|
||||||
|
cleanedContent: stripMarkdownCharacters(removeDiacritics(content)),
|
||||||
path: file.path,
|
path: file.path,
|
||||||
mtime: file.stat.mtime,
|
mtime: file.stat.mtime,
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ export type IndexedDocument = {
|
|||||||
mtime: number
|
mtime: number
|
||||||
|
|
||||||
content: string
|
content: string
|
||||||
|
cleanedContent: string
|
||||||
aliases: string
|
aliases: string
|
||||||
tags: string[]
|
tags: string[]
|
||||||
unmarkedTags: string[]
|
unmarkedTags: string[]
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import {
|
|||||||
removeDiacritics,
|
removeDiacritics,
|
||||||
splitCamelCase,
|
splitCamelCase,
|
||||||
splitHyphens,
|
splitHyphens,
|
||||||
stripMarkdownCharacters,
|
|
||||||
} from '../tools/utils'
|
} from '../tools/utils'
|
||||||
import { Notice } from 'obsidian'
|
import { Notice } from 'obsidian'
|
||||||
import type { Query } from './query'
|
import type { Query } from './query'
|
||||||
@@ -321,10 +320,10 @@ export class Omnisearch {
|
|||||||
results = results.filter(r => {
|
results = results.filter(r => {
|
||||||
const document = documents.find(d => d.path === r.id)
|
const document = documents.find(d => d.path === r.id)
|
||||||
const title = document?.path.toLowerCase() ?? ''
|
const title = document?.path.toLowerCase() ?? ''
|
||||||
const content = stripMarkdownCharacters(
|
const content = (document?.cleanedContent ?? '').toLowerCase()
|
||||||
document?.content ?? ''
|
return exactTerms.every(
|
||||||
).toLowerCase()
|
q => content.includes(q) || removeDiacritics(title).includes(q)
|
||||||
return exactTerms.every(q => content.includes(q) || title.includes(q))
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,7 +332,7 @@ export class Omnisearch {
|
|||||||
if (exclusions.length) {
|
if (exclusions.length) {
|
||||||
logDebug('Filtering with exclusions')
|
logDebug('Filtering with exclusions')
|
||||||
results = results.filter(r => {
|
results = results.filter(r => {
|
||||||
const content = stripMarkdownCharacters(
|
const content = (
|
||||||
documents.find(d => d.path === r.id)?.content ?? ''
|
documents.find(d => d.path === r.id)?.content ?? ''
|
||||||
).toLowerCase()
|
).toLowerCase()
|
||||||
return exclusions.every(q => !content.includes(q))
|
return exclusions.every(q => !content.includes(q))
|
||||||
|
|||||||
Reference in New Issue
Block a user