Renamed "Omnisearch" into "SearchEngine"
This commit is contained in:
@@ -55,7 +55,7 @@
|
|||||||
})
|
})
|
||||||
note =
|
note =
|
||||||
(
|
(
|
||||||
await plugin.omnisearch.getSuggestions(query, {
|
await plugin.searchEngine.getSuggestions(query, {
|
||||||
singleFilePath,
|
singleFilePath,
|
||||||
})
|
})
|
||||||
)[0] ?? null
|
)[0] ?? null
|
||||||
|
|||||||
@@ -144,7 +144,7 @@
|
|||||||
})
|
})
|
||||||
cancelableQuery = cancelable(
|
cancelableQuery = cancelable(
|
||||||
new Promise(resolve => {
|
new Promise(resolve => {
|
||||||
resolve(plugin.omnisearch.getSuggestions(query))
|
resolve(plugin.searchEngine.getSuggestions(query))
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
resultNotes = await cancelableQuery
|
resultNotes = await cancelableQuery
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import {
|
|||||||
import { eventBus, EventNames, indexingStep, IndexingStepType, type TextExtractorApi } from './globals'
|
import { eventBus, EventNames, indexingStep, IndexingStepType, type TextExtractorApi } from './globals'
|
||||||
import { notifyOnIndexed, registerAPI } from './tools/api'
|
import { notifyOnIndexed, registerAPI } from './tools/api'
|
||||||
import { OmnisearchCache } from './database'
|
import { OmnisearchCache } from './database'
|
||||||
import { Omnisearch } from './search/omnisearch'
|
import { SearchEngine } from './search/search-engine'
|
||||||
import { CacheManager } from './cache-manager'
|
import { CacheManager } from './cache-manager'
|
||||||
import { logDebug } from './tools/utils'
|
import { logDebug } from './tools/utils'
|
||||||
import { NotesIndexer } from './notes-index'
|
import { NotesIndexer } from './notes-index'
|
||||||
@@ -33,8 +33,7 @@ export default class OmnisearchPlugin extends Plugin {
|
|||||||
|
|
||||||
public readonly notesIndexer = new NotesIndexer(this)
|
public readonly notesIndexer = new NotesIndexer(this)
|
||||||
public readonly textProcessor = new TextProcessor(this)
|
public readonly textProcessor = new TextProcessor(this)
|
||||||
// TODO: rename to searchEngine
|
public readonly searchEngine = new SearchEngine(this)
|
||||||
public readonly omnisearch = new Omnisearch(this)
|
|
||||||
|
|
||||||
private ribbonButton?: HTMLElement
|
private ribbonButton?: HTMLElement
|
||||||
|
|
||||||
@@ -93,7 +92,7 @@ export default class OmnisearchPlugin extends Plugin {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const searchEngine = this.omnisearch
|
const searchEngine = this.searchEngine
|
||||||
|
|
||||||
this.app.workspace.onLayoutReady(async () => {
|
this.app.workspace.onLayoutReady(async () => {
|
||||||
// Listeners to keep the search index up-to-date
|
// Listeners to keep the search index up-to-date
|
||||||
@@ -208,7 +207,7 @@ export default class OmnisearchPlugin extends Plugin {
|
|||||||
// Map documents in the background
|
// Map documents in the background
|
||||||
// Promise.all(files.map(f => cacheManager.addToLiveCache(f.path)))
|
// Promise.all(files.map(f => cacheManager.addToLiveCache(f.path)))
|
||||||
|
|
||||||
const searchEngine = this.omnisearch
|
const searchEngine = this.searchEngine
|
||||||
if (isCacheEnabled()) {
|
if (isCacheEnabled()) {
|
||||||
console.time('Omnisearch - Loading index from cache')
|
console.time('Omnisearch - Loading index from cache')
|
||||||
indexingStep.set(IndexingStepType.LoadingCache)
|
indexingStep.set(IndexingStepType.LoadingCache)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export class NotesIndexer {
|
|||||||
public async refreshIndex(): Promise<void> {
|
public async refreshIndex(): Promise<void> {
|
||||||
const paths = [...this.notesToReindex].map(n => n.path)
|
const paths = [...this.notesToReindex].map(n => n.path)
|
||||||
if (paths.length) {
|
if (paths.length) {
|
||||||
const searchEngine = this.plugin.omnisearch
|
const searchEngine = this.plugin.searchEngine
|
||||||
searchEngine.removeFromPaths(paths)
|
searchEngine.removeFromPaths(paths)
|
||||||
await searchEngine.addFromPaths(paths)
|
await searchEngine.addFromPaths(paths)
|
||||||
this.notesToReindex.clear()
|
this.notesToReindex.clear()
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ import { sortBy } from 'lodash-es'
|
|||||||
import type OmnisearchPlugin from '../main'
|
import type OmnisearchPlugin from '../main'
|
||||||
import { Tokenizer } from './tokenizer'
|
import { Tokenizer } from './tokenizer'
|
||||||
|
|
||||||
// TODO: rename to SearchEngine
|
export class SearchEngine {
|
||||||
export class Omnisearch {
|
|
||||||
private tokenizer: Tokenizer
|
private tokenizer: Tokenizer
|
||||||
private minisearch: MiniSearch
|
private minisearch: MiniSearch
|
||||||
/** Map<path, mtime> */
|
/** Map<path, mtime> */
|
||||||
@@ -89,7 +89,7 @@ export function getApi(plugin: OmnisearchPlugin) {
|
|||||||
const query = new Query(q, {
|
const query = new Query(q, {
|
||||||
ignoreDiacritics: plugin.settings.ignoreDiacritics,
|
ignoreDiacritics: plugin.settings.ignoreDiacritics,
|
||||||
})
|
})
|
||||||
const raw = await plugin.omnisearch.getSuggestions(query)
|
const raw = await plugin.searchEngine.getSuggestions(query)
|
||||||
return mapResults(plugin, raw)
|
return mapResults(plugin, raw)
|
||||||
},
|
},
|
||||||
registerOnIndexed(cb: () => void): void {
|
registerOnIndexed(cb: () => void): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user