Composite Tag

First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.

What I’m trying to do

I’m trying to manage my reading list using obsidian and I want to tag the thing that I read with composite tag

Things I have tried

I tried to search a way to do composite tag but it seems like there’s no discussion for it

For example let’s say I have this book file
Strong Man with his Girlfriend.md

tags:
  - badass op male mc
    - male mc
    - op mc
    - badass mc
  - gorgeous female mc
    - female mc
    - gorgeous mc

That book contain the tag badass op male mc which is composite of male mc, op mc, and badass mc. It also contain the tag gorgeous female mc which is composite of female mc and gorgeous mc.

Then I have another book that I read
Disastrous Queen.md

tags:
  - badass op female mc
    - female mc
    - op mc
    - badass mc

That book contain the tag badass op female mc which is composite of female mc, op mc, and badass mc

Then

  • when I search the tag female mc I want both of them to show up, this also the same if I try to search op mc both of them will show up
  • I want to be able to search for female mc but not op female mc so it will on show Strong Man with his Girlfriend
  • I want to be able to search op female mc and it only show Disastrous Queen

The format of your tags does not match with the syntax Obsidian uses:

I’m not sure if there’s a good way to denote what you’re talking about. The nested tag offered by Obsidian would typical look like mc/male/badass or mc/op… You can’t combine different nested tag, without creating a new tag.

I think it would be better for you to use nested tags for the different base characteristics, and rather search for multiple of those.

My typical usage of a nested tag would be to have the most generic at the first level, and then more specific traits further down, like human/male/badass. This would allow for tag searches of #human, #human/male, and #human/male/badass, or any specific subpath.

The problem with nested tag is that I’m not sure which trait the character should I prioritize first, like I have this bunch of trait that I want to use and combine but the order is not clear

  • shy
  • beautiful
  • cute
  • cool
  • smart
  • cunning
  • capable

I need to add I’m aware that the syntax is wrong, I’m trying to know is there a way to do composite tag with the thing I’m describing

1 Like

it seems your list of traits is to help define a person / character, so maybe combine them per character… #characterType/trait

something like
#female
#female/shy
#female/beautiful
#female/gorgeous
#female/badass
#female/op
#female/mc

your two books example would look something like this…

Strong Man with his Girlfriend.md
#male #male/mc #male/op #male/badass
#female #female/gorgeous #female/mc

Disastrous Queen.md
#female #female/mc #female/op #female/badass

I want to be able to search for female mc but not op female mc so it will on show Strong Man with his Girlfriend

search tag:#female/mc -#female/op

I want to be able to search op female mc and it only show Disastrous Queen

search tag:#female/mc AND tag:#female/op

In these examples there’s no need for the separate #male and #female tags right?

Since having #male/mc alone is same as having #male & #male/mc ?
It works on tag search for me.

Lets say that I add female/beautiful to “Disastrous Queen” so it have the tag

  • bautiful female mc
    • female mc
    • beautiful mc
    • op mc
    • badass mc

If I have a book contains two female mc, let’s called it “This Two Should Know Better” that I want to define separately
one of them

  • bautiful female mc
    • female mc
    • beautiful mc

and the other is

  • badass op female mc
    • female mc
    • op mc
    • badass mc

How to make It when I filter female+beautiful+op mc It only shows the “Disastrous Queen” and not “This Two Should Know Better”

The mc part is there because I’m not sure if I want to separate male non main character tag if somehow I want to add that, it also just help myself so it’s explicit which one are male, in this case the main character (mc)

In advance I’m sorry for a somewhat lengthy post, but you touch in on multiple subjects which deserves a little explaining and questions you need to answer before moving forward.

First of all I would like to clear out some terms I’m going to use in this post. With type I mean a unique distinguishable characteristic of your characters, where it has to a single value. This could stuff like being either a male or female character, or if you’re into D&D/fantasy either a human or an orc or an elf or a hobbit or … If you’re one of these, you can’t be another.

I’m also going to talk about traits, in the sense that your character might have any number of these characteristics picked from some random (ever expanding?) list of characteristics. A character could be either of shy, beautiful, cure, smart, badass, and so on… And this can be combined in a multitude of ways.

You also need to consider the aspect of whether your characters are only located to any given book, and as such are only described in that particular book, or whether it would make sense to have dedicated notes on the various characters as they reappear in this or that book series or universe. This might affect how you need to describe your characters.

And finally, in this defining section, you’ve described that you need to differentiate between different characters within a given book and you want to do searches only displaying the matches related to that given character. This will also affect how to write the markdown related to describing them.

Using nested tags

I can’t see way to accomplish all of your goals using just nested tags. You could use nested (or composite) tags to describe the type of your characters, but it’ll become very messy when you start describing the different traits of a character. The best way do traits using tags, would be to have dedicated notes for each character, and consider doing something like: #trait/beautiful and #trait/cunning. That is to use multiple tags for each of that characters traits.

In addition if you limit your character description to be in the current note, you’ll have a hard time separating which traits belong to which character, as in the one tag list you can’t connect some of the tags to just one of the characters.

Finally combining each character into one single tag, which although could an option, would make some seriously ugly tags… Like #SomeFemaleName/mc/human/female/shy/beautiful/cunning/capable And I think it would very fast become a nightmare to do searches related to that…

Dedicated notes for each character

If you use dedicated notes for each character, I think it would be one of the easier ways to quickly do searches across the board. I then imagine having properties like the following for each of them, where the note name is the main name of the character, and you could have aliases in the aliases property if need be:

---
type: mc/human/female
traits:
- shy
- beautiful
- cunning 
- capable
books:
- "[[The Woman]]"
---

This would lend itself rather easily to both ordinary searches, and/or dataview queries if you’re into that.

Containing the description within the note

If you insist on keeping the description within each book note, it would have been nice if we could use multi-level properties, as we then could use properties like:

characters:
- name: SomeFemaleName
  type: mc/human/female
  traits:
  - shy
  - beautiful 
  - cunning 
  - capable
- name: SomeDue
  type: mc/human/male
  traits:
  - ugly
  - big
  - strong

The excerpt above is actually legal as property value, but it’ll collapse them into a composed object so it’ll look like:

And it’s kind of a nightmare to update. But it can be used from dataview and some other plugins if I’m not mistaken… Not quite sure how easy it is to do ordinary searches against this structure, though. To some extent you could stuff like section: (ugly male), but it’ll also match on the female part of the other character.

A list in the current note

Another option, which is still keeping the character descriptions within the same note, but allows for different characters to have different description is to use lists (in the example I show to different approaches which both could be used):

- SomeFemaleName #mc/human/female #shy #cunning #capable
- (name:: SomeDude) is a (type:: mc/human/male), known for being (traits:: "ugly", "big", "strong")

Which could render like this:

Now you could do an ordinary search like: line: (ugly male) to find your guy, and this would not include the female. The two variants could easily be queried through dataview, where the female characters focuses on using tags, and the other on using inline fields (with hiding the field name).

Example note with some queries

If you put the the following text in a note, and switch to either live preview (and move outside the queries with the cursor) or reading mode you’ll see how to do some simple queries:

- SomeFemaleName #mc/human/female #shy #cunning #capable
- (name:: SomeDude) is a (type:: mc/human/male), known for being (traits:: "ugly", "big", "strong")
- (name:: SomeOtherDude) is a (type:: mc/human/male), known for being (traits:: "big", "strong")


### Using tags

```dataview
LIST WITHOUT ID character.text
WHERE file = this.file
FLATTEN file.lists as character
WHERE contains(character.tags, "#shy")
```

### Using inline fields

```dataview
TABLE WITHOUT ID
  character.name, character.type, character.traits, typeof(character.traits)
WHERE file = this.file
FLATTEN file.lists as character
WHERE character.name
  AND contains(character.type, "/male")
  AND contains(character.traits, "ugly")
```

In my test vault this displays as:


So, all in all, it’s possible to note stuff related to multiple characters and their type and traits in various ways, and which way is the best one for you depends on your needs and wants. I tend to favor having dedicated notes for each character, as that would easy linking to the same character if/when they reappear in other books.

And at the same time, as long as the multi-level properties are somewhat finicky and don’t look that good, using lists could be an easy way which is also somewhat visually pleasing and easily queryable.

Hope this answers some of your questions related to using composite tag to describe characters from books. :smiley:

1 Like