Smart tags: Key-Value pairs using new nested tags feature

I hope this is a good place to post this idea and would love community feedback on it. I am a researcher in engineering and am often faced with needing to perform literature reviews comparing different solutions to a similar problem. For this description, let’s say I am comparing different devices each with a different size and I want to ask the question “which of the devices I’ve researched would fit into this design?”. I would love the ability to query across all of my notes for the size of all devices and display them in one place along with other related attributes. I use the word “attributes” specifically, because this is the term Roam gives to their key-value pair system that allows you to build a table of all the times that attribute was mentioned.

However, this is not intended as a post asking for Obsidian to mirror Roam’s features. In contrast, I think Obsidian’s new nested tag feature has the opportunity to provide a significantly more elegant solution to this problem.

When I am performing the query on key-value pairs, I don’t want to find all the times “size” was assigned a value. Instead, I want to find all the times “devices/size” was assigned a value. In other words the generic tag “size” gets a qualifier from its parent tag “devices”. This way I can use the tag “size” in several contexts and each has a unique meaning. I could query for “devices/size” or “houses/size” and they would not conflict. In Roam, to do the same thing, I would need to do something like this “[[[[devices]], [[size]]]]:: size of device” which is cumbersome.

So what I am proposing is an additional syntax to go along with the new nested tag functionality in Obsidian that allows you to add a value to a given nested tag. For example “devices/size:: value”. When querying this key-value pair, you could search for “attr: devices/size” and it would list all of the values from your notes assigned to that nested tag. What’s more, it could list along side that (in a table for instance) all of the key-value pairs that share the same parent tags. For example, it would list all of the “devices/color:: value” values alongside the size values.

If the syntax is such that it can be typed in-line with your notes, then you could also query the context around when that key-value pair was assigned. Compared to Roam where attributes are their own blocks and when queried only show you the other attributes at the same block-level as the one being queried. With nested tags, this limitation would be eliminated, allowing you you query and compare values across parent tags regardless of context or “block-level”.

Have you looked into Obsidian’s YAML support? I don’t know if I fully follow your use case but it seems somewhat aligned.

I think I follow you. Wouldn’t using another level of nesting do what you want? e.g. “#devices/size/large”, “#devices/size/medium”, and “#devices/size/small”.

Then a search for tag:#devices/size would return all 3 sizes. One thing I do think might be useful in this case would be a delimiter to use more complex tag names. Then you could have tags like “#devices/size/:: A complex tag name with spaces & special characters ::”.

1 Like

Hi. Sorry for the delayed reply. I’ve taken some time to look into both of your suggestions. The YAML support is very close to what I’m talking about and may work in some situations since this essentially allows for metadata to be added to a “device” that I am studying. I think the limitation is that it only seems to be used for header information whereas I think it would be useful to include these “smart tags” within the body of a note since often times it is during the review of a device and the specific details about it that these characteristics become relevant. It would be nice to embed these characteristics within the context in which they appear.

The idea of using another level of tag is an interesting one too. I think there is benefit to treating a “value” as different than a “tag” though. Specifically in how the results are treated as part of a query. I am imagining being able to build a table listing all of the values for a specific nested tag so I can quickly compare across references. I suppose if a plugin were to treat the final tag in a long list of nested tags differently, it could work as the key-value pair I am thinking of. Specifically your suggestion of using a special syntax to allow for multi-word tags names would go a long way here. Not only would it allow for “values” to be paragraph description of something but it could also give a plugin something to look for to identify it as different than a normal tag. Both of these would be very useful.

I will definitely keep thinking about this idea and how it could be done using Obsidian’s current feature set. Thanks for your feedback!

1 Like