# Composite Tag

**URL:** <https://forum.obsidian.md/t/composite-tag/91121>\
**Category:** Help\
**Created:** [November 6, 2024, 6:27pm UTC](https://forum.obsidian.md/t/composite-tag/91121 "2024-11-06T18:27:06Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![holroy](https://forum.obsidian.md/user_avatar/forum.obsidian.md/holroy/32/77699_2.png) [@holroy](https://forum.obsidian.md/u/holroy)\
**Post date:** [November 15, 2024, 7:25pm UTC](https://forum.obsidian.md/t/composite-tag/91121/10 "2024-11-15T19:25:37Z")

</div>

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:

```auto
---
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](https://forum.obsidian.md/t/properties-support-multi-level-yaml-nested-attributes/63826), as we then could use properties like:

```auto
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:

![image](https://forum.obsidian.md/uploads/default/optimized/3X/f/3/f37f95c8416dc1a77d48e225deac2a7c25290c13_2_690x33.png)

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 _fe **male** _ 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):

```auto
- 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:  
 ![image](https://forum.obsidian.md/uploads/default/original/3X/f/7/f732ad4f54f9050def7171d30d343641ea9a779c.png)

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:
> 
> ````auto
> - 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:
> 
> ![image](https://forum.obsidian.md/uploads/default/original/3X/b/a/baf35bb5f02ffe5e1d4f73718b0d8584519611e2.png)

* * *

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. 😃

---

_[View the full topic](https://forum.obsidian.md/t/composite-tag/91121)._
