Skip to content

A search engine that "just works" for Obsidian. Includes OCR and PDF indexing.

License

Notifications You must be signed in to change notification settings

seyeeL/obsidian-omnisearch

 
 

Repository files navigation

Omnisearch for Obsidian

Sponsor me
Obsidian plugin GitHub release (latest by date and asset)
GitHub release (latest by date including pre-releases) GitHub release (latest by date including pre-releases)

Omnisearch is a search engine that "just works". It always instantly shows you the most relevant results, thanks to its smart weighting algorithm.

Under the hood, it uses the excellent MiniSearch library.

Features

Omnisearch's first goal is to locate files instantly. You can see it as a Quick Switcher on steroids.

  • Find your 📝notes, 📄PDFs, and 🖼images faster than ever
  • Automatic document scoring using the BM25 algorithm
    • The relevance of a document against a query depends on the number of times the query terms appear in the document, its filename, and its headings
  • Keyboard first: you never have to use your mouse
  • Workflow similar to the "Quick Switcher" core plugin
  • Resistance to typos
  • Switch between Vault and In-file search to quickly skim multiple results in a single note
  • Supports "expressions in quotes" and -exclusions
  • Filters file types with '.jpg' or '.md'
  • Directly Insert a [[link]] from the search results
  • Supports Vim navigation keys

Note: support of Chinese, Japanese, Korean, etc. depends on this additional plugin. Please read its documentation for more information.

Installation

You can check the CHANGELOG for more information on the different versions.

Usage

Omnisearch can be used within 2 different contexts:

Vault Search

Omnisearch's core feature, accessible with the Command Palette "Omnisearch: Vault search". This modal searches through your vault and returns the most relevant notes. That's all you need to find a note.

If you want to list all the search matches of a single note, you can do so by using tab to open the In-File Search.

In-File Search

Also accessible through the Command Palette "Omnisearch: In-file search". This modal searches through the active note's content and lists the matching results. Just press enter to automatically scroll to the right place.

URL Scheme & Public API

You can open Omnisearch with the following scheme: obsidian://omnisearch?query=foo bar


For plugin developers and Dataview users, Omnisearch is also accessible through the global object omnisearch (window.omnisearch)

This API is an experimental feature, the ResultNote interface may change in the future. The search() function returns at most 50 results.

// API:
type OmnisearchApi = {
  // Returns a promise that will contain the same results as the Vault modal
  search: (query: string) => Promise<ResultNoteApi[]>,
  // Refreshes the index
  refreshIndex: () => Promise<void>
  // Register a callback that will be called when the indexing is done
  registerOnIndexed: (callback: () => void) => void,
  // Unregister a callback that was previously registered
  unregisterOnIndexed: (callback: () => void) => void,
}

type ResultNoteApi = {
  score: number
  path: string
  basename: string
  foundWords: string[]
  matches: SearchMatchApi[]
  excerpt: string
}

type SearchMatchApi = {
  match: string
  offset: number
}

Dataview Integration

You can use the Omnisearch API directly within the Dataview plugin.

```dataviewjs
const results = await omnisearch.search('your query')
const arr = dv.array(results).sort(r => r.score, 'desc')
dv.table(['File', 'Score'], arr.map(o => [dv.fileLink(o.path), Math.round(o.score)]))
```

CSS Customization

There are several CSS classes you can use to customize the appearance of Omnisearch.

.omnisearch-modal
.omnisearch-result
.omnisearch-result__title
.omnisearch-result__counter
.omnisearch-result__body
.omnisearch-highlight
.omnisearch-input-container
.omnisearch-input-field

See styles.css for more information.

Issues & Solutions

Omnisearch makes Obsidian sluggish/freeze at startup.

  • While Omnisearch does its best to work smoothly in the background, bigger vaults and files can make Obsidian stutter during indexing.
  • If you have several thousands of files, Obsidian may freeze a few seconds at startup while the Omnisearch cache is loaded in memory.

Omnisearch seems to make Obsidian slower.

  • Once Obsidian has indexed your files at startup, it doesn't do anything while its modal is closed. Your changes are not indexed until you open the modal again. If you experience slowdowns while using Obsidian, it's unlikely that Omnisearch is responsible.
  • However, Text Extractor can make Obsidian slower while indexing PDFs and images for the first time. If you don't need those features, you can disable them in the plugin settings.

Omnisearch is slow to index my PDFs and images

  • The first time Text Extractor reads those files, it can take a long time to extract their text. The results are then cached for the text startup.

Omnisearch gives inconsistent/invalid results, there are errors in the developer console

  • Restart Obsidian to force a reindex of Omnisearch.
  • The cache could be corrupted; you can clear it at the bottom of the settings page, then restart Obsidian.

A query should return a result that does not appear.

  • If applicable, make sure that "Ignore diacritics" is enabled.
  • If you have modified them, reset weightings to their original values.
  • Rewrite your query and avoid numbers and common words.

I'm still having an issue

You can write your issue here with as much details as possible.

LICENSE

Omnisearch is licensed under GPL-3.

Thanks

To all people who donate through Ko-Fi or Github Sponsors

JetBrains Logo (Main) logo

About

A search engine that "just works" for Obsidian. Includes OCR and PDF indexing.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 70.0%
  • Svelte 20.0%
  • JavaScript 8.6%
  • CSS 1.4%