# Org-roam-search

**URL:** <https://org-roam.discourse.group/t/org-roam-search/2031>\
**Category:** Development\
**Created:** [September 12, 2021, 12:31pm UTC](https://org-roam.discourse.group/t/org-roam-search/2031 "2021-09-12T12:31:34Z")\
**Posts on this page:** 20\
**Page:** 1

<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 12, 2021, 12:31pm UTC](https://org-roam.discourse.group/t/org-roam-search/2031/1 "2021-09-12T12:31:34Z")

</div>

> **[GitHub - natask/org-roam-search](https://github.com/natask/org-roam-search)**
>
> Contribute to natask/org-roam-search development by creating an account on GitHub.

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.

---

<div class="post-metadata">

**Author:** ![ThomasFKJorna](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@ThomasFKJorna](https://org-roam.discourse.group/u/ThomasFKJorna)\
**Post date:** [September 12, 2021, 5:20pm UTC](https://org-roam.discourse.group/t/org-roam-search/2031/2 "2021-09-12T17:20:56Z")

</div>

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

---

<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 15, 2021, 9:13am UTC](https://org-roam.discourse.group/t/org-roam-search/2031/3 "2021-09-15T09:13:34Z")

</div>

@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

```auto
(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](https://github.com/natask/org-roam-search/blob/679da10768fb651bf74b6729c448b3dd74a24689/org-roam-search.el#L25)

---

<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:** [December 4, 2021, 3:20am UTC](https://org-roam.discourse.group/t/org-roam-search/2031/4 "2021-12-04T03:20:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wuqui](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@wuqui](https://org-roam.discourse.group/u/wuqui)\
**Post date:** [December 4, 2021, 7:45am UTC](https://org-roam.discourse.group/t/org-roam-search/2031/5 "2021-12-04T07:45:17Z")

</div>

Looks cool! 👌

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.

---

<div class="post-metadata">

**Author:** ![ThomasFKJorna](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@ThomasFKJorna](https://org-roam.discourse.group/u/ThomasFKJorna)\
**Post date:** [December 4, 2021, 12:53pm UTC](https://org-roam.discourse.group/t/org-roam-search/2031/6 "2021-12-04T12:53:33Z")

</div>

That is awesome! We could then maybe use this for [Some dashboard-like extensions and 'overviews' for org roam - #34 by ThomasFKJorna](https://org-roam.discourse.group/t/some-dashboard-like-extensions-and-overviews-for-org-roam/1656/34)

(I see you already commented there as well)

---

<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:** [December 4, 2021, 5:27pm UTC](https://org-roam.discourse.group/t/org-roam-search/2031/7 "2021-12-04T17:27:47Z")

</div>

not yet.  
However, It is straightforward to implement dest: and source: . [org-roam-url](https://github.com/natask/org-roam-url/) already does the latter.  
the issue is what type of interface to use. I have made the following [issue](https://github.com/natask/org-roam-search/issues/1) to track the feature. feel free to discuss here or there.

---

<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:** [December 4, 2021, 5:47pm UTC](https://org-roam.discourse.group/t/org-roam-search/2031/8 "2021-12-04T17:47:21Z")

</div>

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](https://github.com/natask/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](https://org-roam.discourse.group/t/linking-multiple-urls-to-an-org-roam-file/777/9). I see that org-roam-ui and delve are now intergrated.

Currently filtering and sorting are conducted within the sql search. if [view tables](https://org-roam.discourse.group/t/some-dashboard-like-extensions-and-overviews-for-org-roam/1656/38) are merged into org-roam, I envision filtering and sorting within emacs will become viable.

---

<div class="post-metadata">

**Author:** ![midas](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@midas](https://org-roam.discourse.group/u/midas)\
**Post date:** [April 6, 2022, 6:54pm UTC](https://org-roam.discourse.group/t/org-roam-search/2031/9 "2022-04-06T18:54:57Z")

</div>

neat. Is it possible to filter out notes with a tag, e.g.`not tag:dontwant` or `-tag:dontwant`?

---

<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:** [May 6, 2022, 1:36pm UTC](https://org-roam.discourse.group/t/org-roam-search/2031/10 "2022-05-06T13:36:25Z")

</div>

yes. the default syntax for negation is !. eg !tag:dontwant  
look at [sexp-string/sexp-string.el at 20b49b2594e97f56729e7c043a2263c4f0e1d8f7 · natask/sexp-string · GitHub](https://github.com/natask/sexp-string/blob/20b49b2594e97f56729e7c043a2263c4f0e1d8f7/sexp-string.el#L126) if you want custom syntax.

---

<div class="post-metadata">

**Author:** ![jasonbraganza](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/jasonbraganza/32/1155_2.png) [@jasonbraganza](https://org-roam.discourse.group/u/jasonbraganza)\
**Post date:** [June 9, 2022, 1:50pm UTC](https://org-roam.discourse.group/t/org-roam-search/2031/11 "2022-06-09T13:50:32Z")

</div>

newbie question.  
because I am new to emacs and org-roam.

i am used to installing packages from elpa/melpa

how do i install org-roam-search though?

because i _really_ need its functionality.

i have just started my org-roam zettelkasten and am a hundred notes in and would love to search by tags or properties

any help appreciated. thank you.

---

<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:** [June 12, 2022, 7:37am UTC](https://org-roam.discourse.group/t/org-roam-search/2031/12 "2022-06-12T07:37:34Z")

</div>

One of these days I will try to place it on melpa. To quickly try it copy paste code in `https://github.com/natask/sexp-string/blob/master/sexp-string.el` and `https://github.com/natask/org-roam-search/blob/master/org-roam-search.el` into an empty buffer and run `eval-buffer`. After that read the readme on `https://github.com/natask/org-roam-search` to see how to use it.  
To have it load with emacs it depends on which emacs distribution you are using. Follow the tutorials for the one you use. the core github repos to include are “natask/org-roam-search” and “natask/sexp-string”.

If you are on doom emacs, place the following code in `packages.el` in `~/.doom.d` and run `doom upgrade`

```auto
(package! org-roam-search
  :recipe (:host github
          :repo "natask/org-roam-search"
          :branch "master"))

(package! sexp-string
  :recipe (:host github
          :repo "natask/sexp-string"
          :branch "master"))

```

I also set up the following in `~/.doom.d/config.el`

```auto
(use-package org-roam-search
    :after (org-roam)
    ;:custom
    ;(org-roam-search-default-tags '("stub"))
    :bind (:map global-map
          (("C-c n f" . org-roam-search-node-find))
            :map org-mode-map
          (("C-c n i" . org-roam-search-node-insert)))
    )

```

---

<div class="post-metadata">

**Author:** ![jasonbraganza](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/jasonbraganza/32/1155_2.png) [@jasonbraganza](https://org-roam.discourse.group/u/jasonbraganza)\
**Post date:** [June 12, 2022, 10:12am UTC](https://org-roam.discourse.group/t/org-roam-search/2031/13 "2022-06-12T10:12:37Z")

</div>

Thank you so much for helping out @savnk! will give it a whirl.

---

<div class="post-metadata">

**Author:** ![wuqui](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@wuqui](https://org-roam.discourse.group/u/wuqui)\
**Post date:** [June 12, 2022, 11:45am UTC](https://org-roam.discourse.group/t/org-roam-search/2031/14 "2022-06-12T11:45:24Z")

</div>

Hey, sounds really cool!

I wanted to give it a try right away, but I get an error message saying that `delve-show` is missing. This happens both when copying and evaluating the contents of the two files you pointed to and when adding your snippets to my Doom config.

I checked your GitHub repo, but only found `delve`, no `delve-show`.

---

<div class="post-metadata">

**Author:** ![jasonbraganza](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/jasonbraganza/32/1155_2.png) [@jasonbraganza](https://org-roam.discourse.group/u/jasonbraganza)\
**Post date:** [June 12, 2022, 11:58am UTC](https://org-roam.discourse.group/t/org-roam-search/2031/15 "2022-06-12T11:58:20Z")

</div>

same here, thought i made some mistake. probably i list of dependancies i need to have installed already? i use vanilla emacs with very few packages installed so far. and everything is currently installed using `package.el`

---

<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:** [June 12, 2022, 5:03pm UTC](https://org-roam.discourse.group/t/org-roam-search/2031/16 "2022-06-12T17:03:15Z")

</div>

sorry guys, I forgot to include `delve-show`. It would be easiest to remove the line `(require delve-show)` from `org-roam-search`. `delve-show` is not critical for the core function of this package. I use it to export search results into a delve buffer, which is a buffer that is aware of org roam constructs, so that I can interact with multiple search results with ease.

I have updated the [read me](https://github.com/natask/org-roam-search/blob/master/README.md) to include quick experimentation and installation guide.

---

<div class="post-metadata">

**Author:** ![jasonbraganza](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/jasonbraganza/32/1155_2.png) [@jasonbraganza](https://org-roam.discourse.group/u/jasonbraganza)\
**Post date:** [June 13, 2022, 7:19am UTC](https://org-roam.discourse.group/t/org-roam-search/2031/17 "2022-06-13T07:19:06Z")

</div>

@savnk you sir, are a mensch! Thank you so much, but I think I am too new, to be doing this  
Will return when I am a bit more experienced with installing stuff in emacs

Right now when I took your advice and put it all in a buffer and removed delve, and then ran `org-roam-search-node-find` or `file-find` then I get a

`concat: Symbol’s function definition is void: s-downcase`

and i don’t want to trouble you further without me knowing what I am doing wrong 🙂

---

<div class="post-metadata">

**Author:** ![wuqui](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@wuqui](https://org-roam.discourse.group/u/wuqui)\
**Post date:** [June 13, 2022, 7:53am UTC](https://org-roam.discourse.group/t/org-roam-search/2031/18 "2022-06-13T07:53:40Z")

</div>

Cool, thanks! Works for me now using Doom 🙂

I’m most excited about the ability to search for nodes with specific (sets of) backlinks.  
I gave it a shot but couldn’t get it to work properly.

For example, which query would I use to get a list of all nodes linking to the nodes ‘foo’ AND ‘bar’? I get (only) false positives when I use `source:foo` or `destination:foo`.

---

<div class="post-metadata">

**Author:** ![wuqui](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@wuqui](https://org-roam.discourse.group/u/wuqui)\
**Post date:** [June 13, 2022, 7:56am UTC](https://org-roam.discourse.group/t/org-roam-search/2031/19 "2022-06-13T07:56:22Z")

</div>

Doom Emacs is a good place to start if you’re new to Emacs. That got me off to a good start two years ago.

---

<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:** [June 13, 2022, 7:31pm UTC](https://org-roam.discourse.group/t/org-roam-search/2031/20 "2022-06-13T19:31:31Z")

</div>

s-downcase is a function within package called s.  
install s from melpa. you may also need to install peg and dash from melpa. (use package-install command to install these).  
like @wuqui said, starting out with doom emacs or in general with another distribution is wise because it comes with majority of the things you will need preinstalled. I started out with spacemacs and switch to doom because I

[Next page](https://org-roam.discourse.group/t/org-roam-search/2031.md?page=2)
