Subsections in org-roam buffer by tag search

I have been using org-roam for several months and a few times I tried out using Obsidian instead. The one thing about Obsidian that I like is how easy it is to use dataview to query the notes’ database and extract all the notes with a given tag or property. You can do this globally or for a given file’s backlinks. For example I can set one section that looks for all backlinks that have my journal tag, or all the backlinks that are bib items (also using tag), and finally another section for all remaining backlinks.

Another example is to have files for contacts all linking to the node of their organization, and then in the organization node show all the people that link to it but in org-roam it all comes mixed with other backlinks, so I’d like to be able to filter it by tag.

That said I still prefer org-roam over obsidian, despite this issue and the limited functionality on mobile (iOS).

My question is in the Org-roam buffer for a given node, how can I rearrange it to use tags’ search to separate the backlinks, to help organizing them. I know that we can add the reflinks section, but that’s it as far as I know how. I also know that it’s possible to query the database but I still haven’t figured it out for either showing in some sort of dynamic blocks in the org file (like Dataview in Obsidian) or in the org-roam buffer.

An alternative is if there is a way to open the org-roam buffer and filter what’s being shown interactively. But I don’t know how to do this either.

Any suggestions?

1 Like

I am not sure if I understand how Obisidian’s dataview works, perhaps

org-roam-dblocks or org-roam-search in GitHub - chrisbarrett/nursery: Programs and libs that I haven't gotten around to formally packaging by Chris Barrett might be useful for what you are trying to achieve. I don’t use them but it seems his features support tag search.

2 Likes

Alternatively, the way @d12frosted does for linking to people/contacts might be a way to achieve what you are going for: Boris Buliga - Task management with org-roam Vol. 6: Select a person and view related tasks

1 Like

Thanks. This actually looks promising. However, I tried to use org-roam-search but the installation instructions failed when I tried to do it from melpa. and when doing from local folder I get a message that cannot find async. I’ll try another time.

If you look at the first code part of the source, you will see this:

;;; Code:

(require 'async)
(require 'dash)
(require 'magit-diff)
(require 'org-roam)
(require 'org-roam-review)
(require 'pcre2el)

You need all of them to be part of your Emacs.

1 Like

Thanks for bringing this up. The following setup seems to be working, as well as installing ripgrep in my machine.

(add-to-list 'load-path "~/.emacs.d/chris-barrett-nursery/lisp")
(use-package org-drill)
(use-package ts)
(use-package pcre2el)
(use-package org-roam-review
  :ensure nil)
(use-package org-roam-search
  :ensure nil
  :commands (org-roam-search))
(use-package org-roam-links
  :ensure nil
  :commands (org-roam-links))
(use-package org-roam-dblocks
  :ensure nil
  :hook (org-mode . org-roam-dblocks-autoupdate-mode))

I guess that the only issue is that this will possibly not work on my windows work machine because of the lack of ripgrep.

But in my research ubuntu machine this is working well.

It’s nice to get a list of all journal entries in a dynamic block in some notes, much like Dataview in Obsidian.
here is the code I use for that, in case anyone is interested:

* Journal
#+begin: backlinks :tags journal
#+end:

then move the cursor to the block and hit C-c C-c to update. Pretty cool.
Thanks @nobiot

I had written org-roam-ql, which might be of interest to you GitHub - ahmed-shariff/org-roam-ql: Query language for org-roam

1 Like

Wow this looks amazing! Great work! Thank you