Find node based on property value?

In org-roam-node-find, how could I filter the results according to property values?
With org-roam-node-display-template, I can display tags. I haven’t found out how to display property values. Is this possible? KR

Yes. You’d be using the way described in this part of the user manual

Some examples are in the wiki.

Depending on your familiarity with Elisp you might struggle to understand what to do. The community here should be able to guide you more if you need. I could also try to help you later this month if you need; just on holidays with no PC.

1 Like

Thank you for response! My familiarity with Elisp is very limited but I’ve figured it out. Really nice that the display-template setup is so flexible. Now I can filter the nodes in helm.

(cl-defmethod org-roam-node-myprop ((node org-roam-node))
(format “(%s)” (cdr (assoc “MYPROP” (org-roam-node-properties node))))
(setq org-roam-node-display-template “${myprop:10} ${tags:30} ${title:100}”)

That is very helpful for the moment. In the long term, I wonder how I could write kind of wrapper functions of org-roam-node-find that do the filtering for me. But I don’t even know if that is an org-roam related question. It is definitely no question for the holiday period!

1 Like

org-roam-node-find takes filter-function as an argument, so writing a wrapper function will be easy. I suggest you look at the docstring (documentation) of the org-roam-node-find:

(cl-defun org-roam-node-find (&optional other-window initial-input filter-fn pred &key templates)
"Find and open an Org-roam node by its title or alias.
INITIAL-INPUT is the initial input for the prompt.
FILTER-FN is a function to filter out nodes: it takes an `org-roam-node’,
and when nil is returned the node will be filtered out.

Thank you. I should have looked there… I applied it to org-roam-node-insert - maybe helpful for other beginners:

(defun org-roam-node-insert-mytype ()
  (org-roam-node-insert  (lambda (node) (equal "MyValue" (cdr (assoc "MYPROP" (org-roam-node-properties node))))) )

1 Like