How to find all files/headings that are linked to a selection of files?

Can I retrieve all files/headings that have links to the files football AND books, for example, to retrieve all football-related books in my collection?

  • The backlinks buffer basically does the same thing, but only with regard to one – namely the currently displayed – file.
  • I know I can search by tags, but I only use tags for very broad categories of files (e.g. private vs. work) and I’m using links for everything else.
  • I also know I can use deft for searching, but I feel this isn’t a very clever way since it’s not taking advantage of all the network information contained in the collection.

Given that I have all these nice semantic “labels” in the form of links, it would be very powerful to be able to perform searches like the toy example above. I would imagine the necessary information should be contained in the database since basically the same thing happens for the backlinks buffer. I was surprised I could not find any information for how to do this. Is there a way? This would be incredibly powerful.

By the way, thanks again for this awesome package! :slight_smile:

Can you be more clear on what you’re trying to do.

I sounds like all you need to do is add notes for football and books, then link each other note you want to show up in the org-roam backlinks buffer to either of those two notes (or more). A note does not have to have text, I have lots of blank notes that are used to connect ideas, basically a tagging or category system, so football and books could be blank targets that act as categories or tags to organize other notes.

If you’re looking for search then deft, or grep are what you might use. Otherwise you’re looking for search packages that work with org-mode, outside of the scope of org-roam.

The thing is that I can use the backlinks buffer of football to find all notes that are related to football. I would want to limit these to notes that are also related to books, however.

I think some people are already using tags for something like this one way or another: e.g., 'show me all notes that are tagged as both football and book'. I would like to do the same thing based on links.

I don’t think this would be possible with what you are describing, but I’m not entirely sure whether I understood you correctly.

Advanced filtering and queries is something that we’re working on for v2. When the database is a little more fixated, we’ll be able to get started on this.

Cool, I’m looking forward to it, thanks :slightly_smiling_face:

One more thought about this: what I have in mind is basically similar to what you can do in org-agenda.

Quoting from the org-mode documentation:

The search string ‘+computer +wifi -ethernet -{8.11[bg]}’ matches note entries that contain the keywords ‘computer’ and ‘wifi’, but not the keyword ‘ethernet’, and which are also not matched by the regular expression ‘8.11[bg]’, meaning to exclude both ‘8.11b’ and ‘8.11g’.

I think I read some time that you are considering to use the org mode tags system for tagging headings. Maybe – under the hood – links could be considered as tags for the current heading. The underlying way of querying might then still be different from what’s behind org-agenda, but at least there would be a well-established interface for querying stuff and maybe also some code that could be re-used?

Having said that, the basic unit for links/tags/queries should probably be headings rather than files. Which is what you’re moving towards anyway in the new version I think, right?

I’ve had a quick look into the SQLite database. I don’t know much about these things, but it seems like this should be pretty easy to implement since all the information is available in the DB.

For example, I used the following query to retrieve the file names of all notes that are related (target of links) to notes that have embedding and change in their file names:

SELECT DISTINCT(source)
FROM links
WHERE dest LIKE "%embedding%"
INTERSECT
SELECT DISTINCT(source)
FROM links
WHERE dest LIKE "%change%"

This is just quick and dirty and far from perfect, of course. But maybe this can be seen as a proof of concept for what I am looking for. And it is already really useful for me even like this.