I’m often frustrated with the very slow search in Obsidian (my one real complaint in this otherwise awesome project). And I haven’t found a community plugin that does a better job.
But the Bases plugin generates lists of files lightning fast. Unfortunately, the API for Bases is not available yet, so the only way to search with Bases is to have a note with a code block.
So I’ve set up 3 notes with the following content, including short aliases for fast access. It’s only a little more clunky than “Search” but if you’ve got a few thousand notes then the speed is worth it.
These can be modified for a new search by clicking the filter icon on the base UI, and expanding the top line, “All views”. There’s also an “Add filter” option at the bottom of the filter interface. You can use this to e.g. filter by folder.
(And with the adjacent icon you can choose what info is displayed – e.g. also list the file folder.)
Side note: if I start with the code given here and then add new filters using the standard interface, then the new filters appear lower down. In the UI they are below the “All views” section; in the code block they appear at the end. This doesn’t seem to matter in practice so I don’t worry about it; maybe someone else has a better way.
tag search.md
---
aliases: [ts, tags search with bases]
---
Tags: #my/PKM/search
*R: [[filename search]].*
[[Obsidian search]] >
**Tags; exclusions:**
```base
filters:
and:
- file.hasTag("foo")
- '!file.hasTag("foo/")'
- '!file.name.contains("template")'
views:
- type: table
name: Table
```
Optional exclusion of sub-tags
Note that I excluded “#foo/”, i.e. all sub-tags of foo. You also have to update this filter when you update the main filter, if you want to exclude sub-tags in the new search.
In most cases I don’t need this, so I just leave it as “foo/” or whatever won’t interfere with my current search.
I excluded templates because I was getting some undesired matches – you might not need that line but it probably won’t hurt.
filename simple search.md
The default here is to “search for all”. You can change this in the filter UI to “search for any” (i.e. Boolean OR). After adding a word hit enter (otherwise the next word you type is considered part of the same string).
If you’re searching for a single word then it doesn’t matter – “search for all”, “search for any” or “includes”.
---
aliases: [fs, filenames search with bases]
---
Tags: #my/PKM/search
*R: [[filename regex search]], [[tag search]].*
```base
filters:
and:
- file.name.containsAll("foo", "bar")
views:
- type: table
name: Table
```
Note: you could also use "includes"and have separate filter entries for each word in the filename.
filename regex search.md
---
aliases: [frs, filenames regex search with bases]
---
Tags: #my/PKM/search
*R: [[filename simple search]], [[tag search]].*
```base
filters:
and:
- /foo/i.matches(file.name)
views:
- type: table
name: Table
```
Note: The i after the regex string makes it case insensitive.
Limitation: Can’t search body text
Bases doesn’t search body text. It can only search properties.
So you can filter by cssclass, description, last_updated etc, but filename, tags and folder (or path) are the most useful properties for my searches.
Is this project made with AI beyond the author’s ability to comprehend how it works? No