reddit / emacs

How do people search their org roam notes?

r0vsdal · 2022-05-04 21:23
I'm just getting started using org roam extensively for all my notes. One particular issue I have experienced is how to search my dailies notes and sort then from newest to oldest? I for example tag my meeting notes with project name / number. Often I want to list all project notes and sort then at the same time, so I easily can look through them. Have tried with ripgrep / deadgrep, but as theese tools run in parallel it won't sort mye notes. Any good solutions to this problem?
redblobgames · 2022-05-04 21:36
I use ripgrep and then sort, using the `--sort=` flag, but this only works if your file metadata is useful for sorting.
nv-elisp · 2022-05-04 23:43
Controversial opinion: they dont.
cuttle_codes · 2022-05-05 00:16
You may be looking for deft: https://jblevins.org/projects/deft/ I use it for searching notes based on content but haven't tried it with a set of well-tagged notes.
[deleted] · 2022-05-05 01:03
[deleted]
mclearc · 2022-05-05 01:21
I use [consult-notes](https://github.com/mclear-tools/consult-notes/tree/main), which is derived from this [consult wiki-entry](https://github.com/minad/consult/wiki/hrm-notes). it sorts notes by recency. Of course, this assumes that you use consult. I also second the other suggestion to use ripgrep. Here's the function I use: ```emacs-lisp (defun consult-notes-search-all () "Search all notes using grep." (interactive) (consult-ripgrep consult-notes-all-notes)) ``` the `consult-notes-all-notes` is a variable that i point to a directory containing aliases of all the files or directories that I have notes in (which includes both an org-roam notes dir and some of my other org-files, plus some random other stuff). `consult-grep` (which I have set to use ripgrep) just treats all the aliased files and dirs as if they were all together and searches them quickly and easily.
akirakom · 2022-05-05 04:13
I'm not using org-roam, but is it possible to use https://github.com/akirak/org-reverse-datetree instead?
drudge007 · 2022-05-05 04:32
I had the same question...I'm rather new emacs and org-roam so take my response lightly. I first tried the deft solution that someone posted, but then found out that Helm actually has a decent option using silver searcher (ag). So my workflow, assuming I'm looking at an org roam note, is C-x C-f to open file, M-g to do something with Helm (I forget), then hit "a" for ag. Type your search term and it returns results from your roam folder. Navigate to the file and hit enter to open it. It evens puts your cursor at the location in the file, pretty nice!
takeonrules · 2022-05-05 04:33
I use `consult-ripgrep` in the project directory. However, I realized that I should write a function that is "search my notes".
ExistingProgram3883 · 2022-05-05 04:38
Other replies mentioned consult several times, however, instead of it's default functionality or custom functions, I rely on [consult-org-roam](https://github.com/jgru/consult-org-roam) which can be found on Melpa. It offers several helpful functions such as `consult-org-roam-search`.
takeonrules · 2022-05-05 04:48
Today I learned about `consult-org-roam`!
dcunit3d · 2022-05-05 06:05
it's easy to set up DSL's in lisp. it's what it's for you can do this with org-roams own interface. it is based on sqlite and there is a query language built on that. access it with `org-roam-db-query`. it's used in the org-roam-ui source. i just saw [this feature request](https://github.com/org-roam/org-roam-ui/discussions/25#discussioncomment-1853898) a minute ago. that comment describes something like what you want: ```emacs-lisp (when extra-attrs (setq properties (caar (org-roam-db-query [:select properties :from links :where (= source $s1) :and (= dest $s2) :limit 1] source path))) (setq properties (append properties extra-attrs)) ``` i wish sourcegraph where a bit easier to set up.
Hurry-Glad · 2022-05-05 14:23
I prefer zk.el https://www.youtube.com/watch?v=BixlUK4QTNk [https://melpa.org/#/zk](https://melpa.org/#/zk) [https://github.com/localauthor/zk/tree/404b52829ad58155f8ba40e507334267ad95e2a1](https://github.com/localauthor/zk/tree/404b52829ad58155f8ba40e507334267ad95e2a1) In the index of notes you can sort notes by date of creation or date of modification. It's also possible to filter notes by contents, tags or keywords in titles, or their combination; later you can save them in a project i.e. zk-desktop to recover a subset of your notes.
oldjawbone · 2022-05-05 16:22
Same ;)
r0vsdal · 2022-05-05 18:57
Interesting, will check out this package.
r0vsdal · 2022-05-05 19:02
Interesting, thanks!
r0vsdal · 2022-05-05 19:03
This is actually what I've been using lately!
nullmove · 2022-05-06 21:39
Yeah I used to do tags, but full text search made that redundant entirely. For the sake of completeness, at some point notes content might become too big for deft and its pure elisp based search to handle (though admittedly I am sceptical if most of us are anywhere near hitting that limit). Then one could look into notdeft[1], which was fork of deft to add xapian based indexing so basically blazing fast search and notmuch like queries, notdeft also has its own featured, and I think it's actually still maintained unlike deft. However iirc, notdeft only uses index when you are using querying feature, but not when you are doing on the fly typing like deft. I find that I don't really need any complex queries so that part of xapian is wasted on me, I only ever use on the fly typing feature. Thankfully there is another package called xeft[2] which does exactly that but with xapian instead. Even though it's functionally barebone, I really like xeft's interface. [1] https://github.com/hasu/notdeft [2] https://github.com/casouri/xeft
danderzei · 2022-05-07 20:51
I have been using Deft but found it slowed down considerable rendering it unsuitable.
AuroraDraco · 2022-05-08 18:24
From what I understand, your problem could be solved using filter/sorting functions in `org-roam-node-read`. Depending on what is unique in your daily notes it should be trivial to write a function to filter to only your daily notes. For example my daily notes are in a folder /daily and I can filter to them by making a predicate function that checks if the value of `org-roam-node-directories` is "daily" or not. Then for sorting them, if they have any kind of metadata you can make a sorting function (for reference check `org-roam-node-read-sort-by-file-atime`). If your problems are just filtering and sorting your notes, then you should have no trouble. You can even insert them in a temporary buffer and view them all simultaneously. Albeit completely unrelated to daily notes, I recently wrote a package to solve this exact problem you describe, but instead of daily notes, I wanted to filter an arbitrary selection of notes. You can check it out [here](https://github.com/Vidianos-Giannitsis/zetteldesk.el), the source might give you some inspiration for how to do what you want. Ripgrep is an excellent tool for searching your notes, but what you are asking for isn't really its use case I feel, you want more of a filter, not a search tool. If you explain your note's metadata more thoroughly, I could even help you with the elisp.
AuroraDraco · 2022-05-08 18:45
This is a great package, but its not for org-roam which was my problem with it, and probably OP would face the same issue. I discovered it looking for such desktop functionality in org-roam, and in the end came to the conclusion that there wasn't a great one and wrote one myself. But from a brief look of this package, its great, but its not for org-roam, which makes it unusable for me.
Khoulaiz · 2022-05-11 09:47
I use consult-ripgrep and have stolen this peace of code from somewhere: (defun ace/org-roam-rg-search () "Search org-roam directory using consult-ripgrep. With live-preview." (interactive) (let ((consult-ripgrep-command "rg --null --ignore-case --type org --line-buffered --color=always --max-columns=500 --no-heading --line-number . -e ARG OPTS")) (consult-ripgrep org-roam-directory))) (global-set-key (kbd "C-c nr") 'ace/org-roam-rg-search)
Nondv · 2022-12-13 04:11
just stumbled upon this post as i'm wondering the same question. What did you end up doing? At the moment I'm seriously considering indexing my notes with elasticsearch and just writing some simple emacs frontend for querying them. Playing around with queries at the moment. Not sure if the overhead is worth it tho