I have the following .md files.
For clarity, I’ll use screenshots instead of markdown.
test_search/test1.md
test_search/test2.md
test_search/test3.md
My purpose is to search all the sections that contain both two tags, i.e. #tag2
and #tag3
.
A naive approach is to use section:(#tag2 #tag3)
, the result is:
- Match section:
- Match all of:
- Matches text: "#tag2"
- Matches text: "#tag3"
- test1 4
- ## test1-heading #tag2 #tag3
- #tag2 #tag3
Note that
-
It included two result instead of 1. The 2nd one is in the code block and they are not tags.
-
I have turn on the “Explain search term”, it shown that engine was matching text rather than tag.
The obsidian doc says that
Note: Since
tag:
ignores matches in code blocks and in non-Markdown content, it’s often faster and more accurate than a normal full-text search for#work
.
Therefore I rewrite the query:
section:((tag: tag2) (tag: tag3))
However it doesn’t work.
The “Explain search term” says
Operator “tag” cannot be nested within “section”.
So is there any way to work around this problem?
Thanks.
P.s. I also tried ((tag: tag2) (tag: tag3)) section:(#tag2 #tag3)
, it still return two results. BTW what does the space (that before “section”) here mean? AND or OR?