# Searching ROAM\_TAGS (or properties generally)

**URL:** <https://org-roam.discourse.group/t/searching-roam-tags-or-properties-generally/753>\
**Category:** Troubleshooting\
**Created:** [September 15, 2020, 5:05am UTC](https://org-roam.discourse.group/t/searching-roam-tags-or-properties-generally/753 "2020-09-15T05:05:43Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ethan](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/ethan/32/307_2.png) [@ethan](https://org-roam.discourse.group/u/ethan)\
**Post date:** [September 15, 2020, 5:05am UTC](https://org-roam.discourse.group/t/searching-roam-tags-or-properties-generally/753/1 "2020-09-15T05:05:43Z")

</div>

I’m curious how one would use ROAM\_TAGS in terms of searching or aggregating based on those values.

A basic example is just related to ROAM\_TAGS. Let’s say I’ve marked a bunch of recipe files with `#+ROAM_TAGS: recipe`. How would I then search for all the files with that tag? If that’s not possible, what is the actual use of marking files with ROAM\_TAGS?

A more complex example: imagine a set of recipe files that have other properties in them like, say, `#+MEAL_TYPE`. How could I search this property to get, say, all the soup recipes?

I’m new to org generally so it could be that my confusion here is also stemming from a confusion about basic org-mode. My sense is that in regular org-mode the practice would be more along the line of having fewer files with multiple entires in them, and that you might filter a single document to show only certain matching entries. Wth org-roam, my sense is that the tendency is rather to create smaller “atomic” files. But if that’s the case in org-roam, you’d want to be able to filter/match on these properties/tags across the files no?

Hopefully someone can set me down the right path here…

---

<div class="post-metadata">

**Author:** ![efim](https://avatars.discourse-cdn.com/v4/letter/e/e9a140/32.png) [@efim](https://org-roam.discourse.group/u/efim)\
**Post date:** [September 15, 2020, 7:55pm UTC](https://org-roam.discourse.group/t/searching-roam-tags-or-properties-generally/753/2 "2020-09-15T19:55:41Z")

</div>

I am not completely sure in my answer, but that could be a starting point.

Partly answer to your question is in org-roam documentation:

> **[Tags (Org-roam User Manual)](https://www.orgroam.com/manual/Tags.html#Tags)**

tags are firstly for elist functions and commands, they allow to add metadata to the file that would influence for example how is that file displayed in an interactive command.

Overall in Org Mode #+something is a file property  
Here #+roam\_tags is a specific property that is created specifically for org-roam functioning  
(And I don’t know specific examples for how it is used)

–  
For your situation you could use org-roam linking  
i.e have a separate org-roam file for “soup”  
and from inside of each soup recipe link to the “soup”

Then on the “soup” page the backlinks would contain all the recipes

---

<div class="post-metadata">

**Author:** ![danderzei](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/danderzei/32/59_2.png) [@danderzei](https://org-roam.discourse.group/u/danderzei)\
**Post date:** [September 15, 2020, 8:59pm UTC](https://org-roam.discourse.group/t/searching-roam-tags-or-properties-generally/753/3 "2020-09-15T20:59:35Z")

</div>

There is a nice roundabout way to do what you want to do using the Hugo website generator.

Hugo understands Org Mode files by default.

If you store all your org files in the content folder of a Hugo setup, then you can create tags as you see them fit, i.e.

#+title: This is a recipe  
#+tag: recipe  
#+ingredients[]: potatoes cream chicken bread

When you generate the website, Hugo creates category pages. You don’t have to publish the site s Hugo has its own web server.

Just a thought…

I also don’t understand what the purpose of #+roam\_tags is.

---

<div class="post-metadata">

**Author:** ![jethro](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@jethro](https://org-roam.discourse.group/u/jethro)\
**Post date:** [September 17, 2020, 6:40am UTC](https://org-roam.discourse.group/t/searching-roam-tags-or-properties-generally/753/4 "2020-09-17T06:40:01Z")

</div>

ox-hugo uses `#+HUGO_TAGS`, I don’t think this is an Org-mode thing. Afaik, Org-mode uses `#+filetags`. It’s easy to add more sources of obtaining tags (e.g. you can also add a source to include items from `#+tag`).

Basically if you don’t see the need for tagging, then you don’t really have to worry about it. I don’t manually tag my notes, I just use the directory name as a tag, so as to separate literature notes from concept notes.

---

<div class="post-metadata">

**Author:** ![ethan](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/ethan/32/307_2.png) [@ethan](https://org-roam.discourse.group/u/ethan)\
**Post date:** [September 18, 2020, 1:11am UTC](https://org-roam.discourse.group/t/searching-roam-tags-or-properties-generally/753/5 "2020-09-18T01:11:47Z")

</div>

The original question wasn’t about tags specifically as much as it was about properties, and how you might use them to do searching/filtering in a org-roam workflow. I suppose I discovered along the way that I don’t know what you would do with roam\_tags once applied, but the question is maybe better thought of in terms of the recipe example I gave. Let’s say I’d I added a property meal\_type to a set of files and wanted to view all recipes where that property included the value “dinner”? I guess one could add to that scenario that all the recipes had a roam\_tag value “recipe”…

---

<div class="post-metadata">

**Author:** ![jethro](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@jethro](https://org-roam.discourse.group/u/jethro)\
**Post date:** [September 18, 2020, 6:58am UTC](https://org-roam.discourse.group/t/searching-roam-tags-or-properties-generally/753/6 "2020-09-18T06:58:28Z")

</div>

So it seems like you want to be able to perform bulk queries on your Org-roam files. This seems like a task that [org-ql](https://github.com/alphapapa/org-ql) already neatly solves.

> [@ethan](#):
>
> I don’t know what you would do with roam\_tags once applied

I’m not sure either, since I don’t tag manually at all. But I’m happy to hear from people who use it extensively in their workflows.

---

<div class="post-metadata">

**Author:** ![ethan](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/ethan/32/307_2.png) [@ethan](https://org-roam.discourse.group/u/ethan)\
**Post date:** [September 18, 2020, 4:54pm UTC](https://org-roam.discourse.group/t/searching-roam-tags-or-properties-generally/753/7 "2020-09-18T16:54:11Z")

</div>

@jethro org-ql looks very promising! Thank you for the tip.

On the matter of roam\_tags: so when you organize thing into sub directories that isn’t necessarily for the purpose of “tagging” the files within, but just file system organization? You never query the tags in any way?

---

<div class="post-metadata">

**Author:** ![ethan](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/ethan/32/307_2.png) [@ethan](https://org-roam.discourse.group/u/ethan)\
**Post date:** [September 18, 2020, 6:51pm UTC](https://org-roam.discourse.group/t/searching-roam-tags-or-properties-generally/753/8 "2020-09-18T18:51:11Z")

</div>

@jethro I wonder if you have something you could share in terms of how you use org-ql with org-roam. I’ve installed org-ql, but am having a hard time understanding how it can be configured to look at the files in my org-roam notes directory. I have things laid out as:

```auto
~
|--org
   |--notes ;; org-roam notes

```

org-ql does not search recursively and so I somehow need to point it to the `org/notes` directory. I was playing around with `directory-files` but was struggling to get this to work since this fn seems to pull in directory file paths as well as file file paths, causing org-ql to fail.

Wonder if you’ve solved this already in some way…?

---

<div class="post-metadata">

**Author:** ![ethan](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/ethan/32/307_2.png) [@ethan](https://org-roam.discourse.group/u/ethan)\
**Post date:** [September 18, 2020, 7:16pm UTC](https://org-roam.discourse.group/t/searching-roam-tags-or-properties-generally/753/9 "2020-09-18T19:16:09Z")

</div>

I’m also curious how you create files as it appears from [this thread](https://org-roam.discourse.group/t/how-to-use-sub-directories/136/2) that there’s now easy way to create an entry in a subdirectory.

---

<div class="post-metadata">

**Author:** ![jethro](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@jethro](https://org-roam.discourse.group/u/jethro)\
**Post date:** [September 19, 2020, 6:34am UTC](https://org-roam.discourse.group/t/searching-roam-tags-or-properties-generally/753/10 "2020-09-19T06:34:14Z")

</div>

I don’t use org-ql myself, my workflows are much simpler (and perhaps suboptimal). I just write down things that seem important, and try to make sure they can resurface when they should later on. I don’t query tags in any way, yes. They are just a visual guide in the interactive commands for me.

I create all files through the org-roam-capture interface, you can specify the sub directory via the `:file-name` attribute in the capture template.

---

<div class="post-metadata">

**Author:** ![savnk](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@savnk](https://org-roam.discourse.group/u/savnk)\
**Post date:** [September 21, 2020, 3:27pm UTC](https://org-roam.discourse.group/t/searching-roam-tags-or-properties-generally/753/11 "2020-09-21T15:27:35Z")

</div>

if you already use org-roam then you can search the database org-roam generates. for example to find all files with tag “people”.

```auto
    (setq-local db (emacsql-sqlite3 (expand-file-name "org-roam.db" org-roam-directory)))
    (defun my/org-roam-files-with-tag(tag)
      (emacsql db
                [:select [file]
                         :from tags
                         :where (like tags $r1)] (format "%%%s%%" tag)))
    (print (-flatten ( my/org-roam-files-with-tag "people")))

```

---

<div class="post-metadata">

**Author:** ![bepolymathe](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/bepolymathe/32/688_2.png) [@bepolymathe](https://org-roam.discourse.group/u/bepolymathe)\
**Post date:** [April 20, 2021, 8:01am UTC](https://org-roam.discourse.group/t/searching-roam-tags-or-properties-generally/753/12 "2021-04-20T08:01:13Z")

</div>

Does anyone search their org-roam database with org-ql?
