Search for term from the header in a specific folder - Dataview or regular search?

What I’m trying to do

I’m trying to create a note that represents a Chinese character - the specific character will probably be in the YAML header since I usually name the note with the character + Englsh translation.

Within the note, I’d like to have a list of all the places this character appears within files within a specific folder. Once set up, I’d like to add this to a Chinese character template where it will automatically pull the character and create the search in the note.

Things I have tried

I searched and saw how to run search queries within notes. But I didn’t see a way to limit this to a specific folder.

I’m fairly new to Dataview and wasn’t sure how to return a list of locations where the character appears (based on my limited experience, it seemed that it would show me a list files).

Using Dataview with normal DQL queries you can’t actually search the text of notes, only the metadata such a defined fields, and file titles and statistics and so on. If you switch to the DataviewJS the javascript variant, you can with some work search every text of every note, but it does come at a cost of doing javascript and being reliant on reading files yourself.

With that being said, you might get far using inline queries:

your search text

Using the example above you can insert this into any note, and do just the same as you can do in the vault search within Obsidian. This should be possible to customise into searching for any given chinese character and list the surrounding text of that character. Just as in a normal search.

When you switch to reading view, or leave the block (and you’re in live preview), it’ll do the search, and display the search result.

1 Like

Thank you, holroy! That works.

Is there a way for the inline query to pull the search term from the YAML so I can set up a template?


I don’t think so, but there is a template tag for the current note name ({{title}}). You’d have to reverse your usual practice to use it, but it’s an option.

To limit searches to a specific folder, use -path: in addition to the search term. Search - Obsidian Help

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.