Go to file
Simon Cambier c2ecdd79ad Squashed commit of the following:
commit ac82511ddd17d5472ae3cfea9bbad9754f5a4d62
Author: Simon Cambier <simon.cambier@protonmail.com>
Date:   Sat Oct 22 08:23:42 2022 +0200

    Screw that cache, seriously.

commit 8ba40d1be73daaaffea09e07bc56c339266db9b6
Author: Simon Cambier <simon.cambier@protonmail.com>
Date:   Fri Oct 21 22:36:48 2022 +0200

    Stuff

commit 27b8fd7dc809be9714a109d3a458eb1276a47e2e
Author: Simon Cambier <simon.cambier@protonmail.com>
Date:   Fri Oct 21 22:22:20 2022 +0200

    Moved files

commit fb1349c914907e586e103ca54fb04b9ddd45ef5d
Author: Simon Cambier <simon.cambier@protonmail.com>
Date:   Thu Oct 20 22:25:29 2022 +0200

    Removed duplicate code

commit e7371138e60cbe4155cfd4fb44e3ee1d2e3ee088
Author: Simon Cambier <simon.cambier@protonmail.com>
Date:   Thu Oct 20 21:50:09 2022 +0200

    Moved a bunch of files

commit 2ee1b2a0e799d4b41ab3a444d8cc44dfff5b5623
Author: Simon Cambier <simon.cambier@protonmail.com>
Date:   Thu Oct 20 21:32:21 2022 +0200

    Removed useless code

commit 76c530dfb9adbad1bbe9079de2330fe43a044249
Author: Simon Cambier <simon.cambier@protonmail.com>
Date:   Thu Oct 20 20:44:11 2022 +0200

    Split file reading and indexing
2022-10-22 08:25:34 +02:00
2022-04-20 18:00:55 +02:00
2022-10-22 08:25:34 +02:00
2022-04-23 17:13:48 +02:00
2022-09-21 13:10:25 +02:00
2022-10-11 21:54:11 +02:00
2022-04-09 10:44:54 +02:00
2022-09-21 08:29:11 +02:00
2022-10-11 21:54:11 +02:00
2022-10-11 21:54:11 +02:00
2022-10-02 21:54:20 +02:00
2022-05-17 14:02:13 +02:00
2022-04-18 16:28:14 +02:00
2022-10-18 22:21:03 +02:00
2022-10-02 22:27:00 +02:00
2022-10-18 22:21:03 +02:00
2022-10-16 16:58:10 +02:00
2022-05-11 16:09:42 +02:00
2022-04-30 21:32:24 +02:00
2022-10-18 22:21:03 +02:00

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

  • 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
  • Can search other plaintext files and PDFs (configurable in settings)
  • Workflow similar to "Quick Switcher" plugins
  • Keyboard first: you never have to use your mouse
  • 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
  • Directly Insert a [[link]] from the search results
  • Respects Obsidian's "Excluded Files" list - results are downranked, not hidden
  • Optional support for Vim navigation keys (ctrl + j, k, n, p)

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:

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.

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.

Public API

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

If you're a plugin developer, you can use this "plugin-api" package, and get the api through pluginApi('omnisearch').

Otherwise, you can access it with app.plugins.plugins.omnisearch.api.

// API:
{
  // Returns a promise that will contain the same results as the Vault modal
  search: (query: string) => Promise<ResultNote[]>
}

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

type SearchMatch = {
  match: string
  offset: number
}

Dataview Integration

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

```dataviewjs
const results = await app.plugins.plugins.omnisearch.api.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

For example, if you'd like the usual yellow highlight on search matches, you can add this code inside a CSS snippet file:

.omnisearch-highlight {
    color: var(--text-normal);
    background-color: var(--text-highlight-bg);
}

See styles.css for more information.

Issues & Solutions

Omnisearch makes Obsidian sluggish at startup.

  • You may have big documents. Huge notes (like novels) can freeze the interface for a short time when being indexed. Enabling the setting "Persist cache on disk" may help you in this case.

I have thousands of notes, and at startup I have to wait a few seconds before making a query, or else Omnisearch does not return all the expected results.

  • Enabling the setting "Persist cache on disk" may help you in this case.

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

  • Go in Omnisearch settings.
  • If applicable, disable and re-enable "Persist cache on disk".
  • Restart Obsidian to clear the cache and force a reindex.

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.

How do I highlight matches in search results?

See here.

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.

Sponsors

JetBrains Logo (Main) logo

Description
No description provided
Readme GPL-3.0 7.4 MiB
Languages
TypeScript 74.4%
Svelte 19.4%
JavaScript 4.9%
CSS 1.3%