Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on lemmy.world
obsidianmd·ObsidianMDbylaurelinae

How to search for notes with empty YAML option?

How can I search for notes using the built-in search plugin, which supports regex, to search for notes that have no entry in specific keys within the frontmatter?

I am using templater and thus am using my frontmatter looks like this:

---

aliases:

publish: false

tag:

---

%%

date:: [[2023-07-11 Tue]]

parent:: [[XYZ]]

%%

Searching for "parent:: " works fine, but I want to find notes that do not have a parent note yet. For this I tried parent:: /$ as indicated here and here, but this and other variations like parent:: /\$/ do not yield any results.

Where am i going wrong?

View original on lemmy.world
5

4 replies

lemmy.world

I don't think the built-in search has this capability, but you can try this dataview query:

LIST
WHERE !parent
6

Works like a charm! I didn't know that I could query not just from tags but from any YAML key. Thank you!

2
slrpnk.net

If you're using regex I'm assuming you know of utilities like Regex 101 to check your syntax.

With JS-styled regex the entire statement is enclosed in slashes. /parent:: $/ should have the desired effect here.

I second DataView for these kinds of tasks as the plugin revolves around YAML frontmatter. I have a utility note called "notes with cleanable metadata" that has a bunch of these DataView queries that update in real time.

Good luck!

2

/parent:: $/

Works perfectly! I thought I could start the regex in the middle of my text query. In hindsight, that of course makes no sense. Thank you!

2

You reached the end

How to search for notes with empty YAML option? | Spyke