Org-roam-search

search org roam database using org-ql type syntax.
For example, the following query
tag:tag1,tag2 title:title1,title2 both:query1,query2 query3 query4

searches for file with tag tag1,tag2,query1,query2,query3 and query4 and has in titles/aliases title1,title2,query3 and query4.

alpha software. I have been using it daily as a drop-in replacement for org-roam-find-file.

works with org-roam version 1. It can be easily ported to org-roam verison 2.

4 Likes

Very cool! @KirillR and I have been thinking about something like this wrt org-roam-ui. Do you think this could somehow:

  1. Do queries like: have tag X and be linked to files/nodes with tag Y?
  2. Eventually be combined with org-ql like queries? So you could do something like: show all nodes with tag X and Deadline Y? This could probably already be done in here, since org-roam stores all org properties, but there are probably things org-ql can look for that aren’t stored in the org-roam-db
1 Like

@ThomasFKJorna

It uses org-ql like queries. Search string to sexp conversion code is from org-ql. Like org-ql, you can define custom search types.
Both features you propose are possible. You would need to define a search type and appropriate transform and stringify form for it.
Transfrom converts the search type into a searchable entity. For example, the search term
tag:tag1,tag2 is transformed to

(and  (like tags:tags tag1)
      (like tags:tags tag2))

which is a valid where clause for emacs-sql.

Stringify form displays the search term appropriately within helm or consult. for example, the search string tag:tag1,tag2 query1 query2
is stringified to
(tag1,tag2) query1 query2
look at org-roam-search/org-roam-search.el at 679da10768fb651bf74b6729c448b3dd74a24689 · natask/org-roam-search · GitHub

I have upgraded to org roam search to support org roam v2.

now supports out of the box filtering by titles, tags, olp, level properties of nodes.
sorting is also implemented but not at the prompt level. Users will need to write a sorting clauses compatible with order-by sql clause.

2 Likes

Looks cool! :ok_hand:

There’s no way to search for nodes that contain certain backlinks, is there? For example, to search for all nodes that link to Node A and Node B.

That is awesome! We could then maybe use this for Some dashboard-like extensions and 'overviews' for org roam - #34 by ThomasFKJorna

(I see you already commented there as well)

not yet.
However, It is straightforward to implement dest: and source: . org-roam-url already does the latter.
the issue is what type of interface to use. I have made the following issue to track the feature. feel free to discuss here or there.

1 Like

Yes. I currently have an integration between org-roam-search and delve.

My current workflow is search stuff with org-roam-search. Display results in a persistent fashion using delve-show which works like embark-export and can shuttle query string back and forth org-roam-search. And find nodes linking to urls from the browser using org-roam-url. I see that org-roam-ui and delve are now intergrated.

Currently filtering and sorting are conducted within the sql search. if view tables are merged into org-roam, I envision filtering and sorting within emacs will become viable.