Skip to content

add AND/OR and hash tag search modes#718

Open
aleksejkrueger wants to merge 6 commits into
obsidian-nvim:mainfrom
aleksejkrueger:feat/tag-search-modes
Open

add AND/OR and hash tag search modes#718
aleksejkrueger wants to merge 6 commits into
obsidian-nvim:mainfrom
aleksejkrueger:feat/tag-search-modes

Conversation

@aleksejkrueger
Copy link
Copy Markdown

@aleksejkrueger aleksejkrueger commented Mar 1, 2026

Add AND/OR and hash tag search modes #719

Motivation:

I wanted a better way to search for specific tags in my notes. The previous tag search was limited, so I built this to make it easier and more flexible to find exactly what I need. Now, searching by tags is much more powerful and enjoyable.

Features:

  • Added AND mode (+tag) to require all specified tags, and OR mode (default) to match any tag.
  • Added hash search (#tag) to find tags outside YAML frontmatter, with line and column info for each match.
  • Picker now shows matched tags, search mode (AND/OR), and only shows the file where the tags occur if multiple tags are passed.

Example usage:

  • :ObsidianTags #tag1 — finds all notes with the tag tag1 outside YAML frontmatter.
  • :ObsidianTags +tag1 tag2 — shows only files that have both tag1 and tag2 tags. 1
  • :ObsidianTags tag1 tag2 — finds notes with the tag1 or tag2 tags (OR mode by default).

This update makes organizing and finding notes by tags much smoother and more efficient.

Footnotes

  1. The first + before a tag is sufficient to activate AND mode for searching.

@aleksejkrueger aleksejkrueger changed the title add AND/OR and hash tag search modes (feat/#719): add AND/OR and hash tag search modes Mar 1, 2026
@aleksejkrueger aleksejkrueger changed the title (feat/#719): add AND/OR and hash tag search modes add AND/OR and hash tag search modes Mar 1, 2026
@neo451
Copy link
Copy Markdown
Member

neo451 commented Mar 1, 2026

decent proposal!

  1. need to properly document the DSL in docs/Tags.md and double check if this breaks current behavior
  2. to find inline tags, you can just look into how search.search_tags_async works, and identify which are inline and which are frontmatter, and differentiate with some boolean field in tag location type, like inline. of in_frontmatter. so that you can just filter them in the command implementation instead of read the files again.
  3. feat: obsidian search terms #542 is also on the roadmap, just for your reference, that one is AND mode by default, which makes sense for greping
  4. need some tests, can be tricky to write, I have not write any tests for the commands yet, just run the commands with the queries, and mock Obsidian.picker.pick, and verify the entries are correct

@aleksejkrueger aleksejkrueger force-pushed the feat/tag-search-modes branch from 024f6a1 to 964490b Compare April 30, 2026 20:10
@aleksejkrueger aleksejkrueger force-pushed the feat/tag-search-modes branch from 4fbc001 to c138195 Compare May 1, 2026 16:03
@aleksejkrueger
Copy link
Copy Markdown
Author

hi,

i used ai to generate this feature with obsidian search terms as the reference point, using the official search behavior here: https://obsidian.md/help/plugins/search#search+terms

this should be reviewed carefully by a maintainer before integration. it’s up to the dev team to decide whether the implementation is correct, whether the behavior matches project expectations, and whether it should be merged as-is or adjusted further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants