Use case or problem
Frequent situation: I search for term1 but only in context of term2. For example I search for “Linking
” but only within files that mention also “Obsidian
”.
Search string produces thousands of irrelevant results which I have to carefully scroll to visually find the relevant one.
Example:
linking Obsidian -path:(MyPath)
↓
file1
- ...Obsidian...
- .....Obsidian.
- Obsidian......
- ..Obsidian....
file2
...
fileN
- ...Obsidian...
- Obsidian......
- ..Obsidian....
- ...linking...
- ..Obsidian....
...
Proposed solution
Take inspiration from regular expressions (Non-capturing match).
Implement search operator that does not modify interpretation of search string
except that associated/enclosed search terms are not listed in search results.
The operator could be named e.g. “filter:
” or preferably concise “+
”, the opposite of “-
”.
Example from above would change to:
linking +Obsidian -path:(MyPath)
or
linking filter:(Obsidian) -path:(MyPath)
↓
fileN
- ...linking...
fileM
- ...linking in Obsidian...
This approach might result in matching files without any captured results. List of search results needs to be able to report files without particular results.
Example:
( backlink OR +(linking OR linked) ) +Obsidian -path:MyPath
↓
file1
- ...backlink...
fileN // FileN matches query but does not contain any search result.
fileM
- ...backlinks in Obsidian...
additional thoughts
The wordy method with “filter:
” is easier to intuitively understand by new reader than “+
”. But harder to read and edit and time consuming during frequent searches by experienced user. Both “filter:
” and syntactic sugar “+
” could work in parallel if there is no agreement on preferred syntax.
keywords: exclude, filter, global, hide, restrict context, search
Current workaround
- sought after in help-thread: How to query lines with "string2" inside files with "string1"
Related feature requests
- This might well be specific proposal for Filtering Everywhere!
- similar issue/usecase in backlinks / unlinked mentions: YAML Property to exclude a file / path from the current note's backlinks?
- keyword: indexing