Folder-specific search

I am using Obsidian to manage work-related notes, including a notes for troubleshooting problems and logging issues and their solutions. I organize notes in a very hierarchical way, which I know may not be what Obsidian was designed for.

I’m finding that it is easier to navigate notes in Obsidian without the file explorer in the sidebar, since it tends to be cluttered with things like folders to store notes images, templates, etc. I need to be able to use these to create content but I want to be able to use Obsidian primarily to view / explore content.

I’m using the Folder notes and Waypoint plugin to help make ways to navigate notes.

The one feature I’m missing is a folder-specific search that lives outside of the sidebar. I have been looking for either a search that I can embed inside a note, or another option would be a context-specific search in the Obsidian interface, but not in the sidebar.

1 Like

Perhaps embedded queries will achieve what you want? There are operators for specific content, tags, and even paths (folders). You can put these pretty much anywhere you want. Maybe not a pretty as a clickable magnifying glass, but it works.

The relevant help page that lists all options: Search - Obsidian Help

1 Like

Can you explain this further? What do you want to achieve exactly with that extra search panel? You can use Obsidian URI to trigger search and then Shell commands to query current folder. You can then create a dynamic command that will perform a search in the current folder. Alternatively you can generate the search URL into your notes/properties or bookmarks. Bookmarks offer to create searches without using Obsidian URI. Using bookmarks isn’t as dynamic solution as the option to use Shell commands. The configuration in the plugin for your use case is quite simple so you might get more detailed assistance from other users here (unless you can figure out everything by yourself).

For dynamic output (without needing dataview), insert into a note e.g…

```query
path:"cs/km/mindmaps/" file:"DO" 
```

dynamic output

PS: The query control plugin(BRAT or manual install) adds more controls.

Searches based on Search - Obsidian Help

Search syntax
Combining sub-queries
When crafting a search query, remember that clicking "Explain Search Term" will give an explanation of what is being searched for, which can be very useful when debugging a complicated search.

Words in the search query separated by space will be searched independently in each note. For example foo bar will find a note that includes both foo and bar anywhere in it.
"Quoted strings" can be used to search multiple consecutive words separated by space, or in other words, a phrase. So, searching for "foo bar" with quotes will only find notes that include those words next to each other. You can use backslash \" to escape double quotes if you actually want to search for a string that includes quotes. And \\ will do the same for backslash.
Boolean operations can be used. Use OR to match one or another. Use - to negate a query. The space character is used for boolean "and".
For example: foo OR bar will find all notes that contain either of those words, they don't have to be in the same note. foo -bar will find all notes that contain foo, but not if they also contain bar.
Parenthesis can be used to group boolean operations. For example ((a OR b) (c OR d)). This can be useful when crafting complex searches to make sure things happen in the order you want.
REGULAR EXPRESSIONS (REGEX) can now be used in search. Use forward slash to denote a regular expression. For example: /[a-z]{3}/. Obsidian accepts the JavaScript flavor regular expressions. You can learn more about it here.
Search operators
Several special operators are available. Some operators allow nesting queries using parenthesis, for example: file:("to be" OR -"2B"). You can use - to exclude specific results from search, for example: foo -tag:#bar.

file:(...) will perform the following subquery on the file name. For example: file:.jpg. If you use Zettelkasten-style UIDs, this can be useful for narrowing a time range, for example file:202007for files created in July of 2020.
path:(...) will perform the following subquery on the file path, absolute from the root. For example: path:"Daily Notes/2020-07".
content:(...) will perform the following subquery on the file content. For example: content:"happy cat".
match-case:(...) and ignore-case(...): will override the case sensitive match logic for the following subquery.
tag: will search for your specified tag within a file, for example tag:#work. This is faster and more accurate than searching for the tag in plaintext #work, as it uses the cached information and ignores text in code blocks and sections that aren't markdown text.
line:(...) will perform the subquery on a line-by-line basis, rather than a file-by-file basis. For example, if you search for foo bar, this could match a file that has foo in the first paragraph and bar in the last paragraph. Searching for line:(foo bar) will only match if foo and bar are on the same line.
block:(...) will perform the subquery on a block-by-block basis. A markdown block is separated by empty lines. In the context of this command, list items are also considered as separate blocks. This is expensive computationally as it requires parsing each file, which means this is likely slower than other modes.
section:(...) will perform the subquery on a section-by-section basis, where each section is the text between two headings, including the first heading.
task:(...) will perform the subquery only on each task and on a block-by-block basis. Use task:"" to match all tasks.
task-todo:(...) will perform the subquery only on each uncompleted task and on a block-by-block basis. Use task-todo:"" to match all uncompleted tasks.
task-done:(...) will perform the subquery only on each completed task and on a block-by-block basis. Use task-done:"" to match all completed tasks.

Personally I bookmark all my important searches, including search templates, so to have them easily available in the sidebar.

However you could just create them as dynamic queries in one or more notes.

In my search/query templates I use “xyzxyz” and regex /xyzxyz/ so that they don’t fire and I can fill in what I actually want to search for at the time.

My dynamic queries templates note is quite large with non-active ones
<!-- commented out. →

Here is a small excerpt (1st one: regex) …

<!--

```query
file:/.*xyzxyz.*/ 
```
```query
path:"xyzxyz" file:"xyzxyz" content:"xyzxyz"
```
```query
path:"xyzxyz" file:"xyzxyz" 
```
```query
path:"xyzxyz"  content:"xyzxyz"
```
```query
file:"xyzxyz" content:"xyzxyz"
```
```query
file:"xyzxyz"
```
```query
content:"xyzxyz"
```
-->

active query:

```query
path:"cs/km/mindmaps/" file:"DO" 
```

Thanks for the suggestions, I am new to Obsidian and am trying to see how to make it work for what I need.

@Erisred embedded queries are nice but not being able to edit the query in View mode makes them not work for what I was hoping for.

@blue_emperor by shell commands do you mean to make a command outside of Obsidian?

I’m probably investigating using Obsidian for something it wasn’t designed for, as a CMS for work-related documents and documentation. I need both a tool for myself to write down notes about things I am working on, and a place to ‘publish’ those notes into documentation that can be shared with colleagues. Obsidian seems to work well for my own notes, but not sure about the other part. Having an easy to use way to search through those ‘published’ documents is what I’m hoping for, so something intuitive, and it is helpful to limit the search to a sub-section of the content.

Obsidian Publish looks good, but I’m not sure about the limitation of not being able to edit things on the fly if needed. It has a built-in search. I think the adjustment I need to make is to separate the content into different vaults in order to allow search within that specific subsection. So for example I could move issue tracking and troubleshooting notes into their own vault.

I wrote a simple plugin for my own use that defines two hotkeys:

  • search active folder
  • search closest folder (where the folder is matching a name, closest to the current active file)

Not sure if this would be useful or if you would need more hotkeys or some other setup for your CMS.