Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add query option for full-text search #6

Open
claudiusmueller opened this issue Feb 11, 2024 · 2 comments
Open

add query option for full-text search #6

claudiusmueller opened this issue Feb 11, 2024 · 2 comments

Comments

@claudiusmueller
Copy link

The Org-roam-ql approach to querying org-roam notes is great. There is just one missing piece to the puzzle - a query option to search the body of the notes.

There are always pieces of information that I did not think to capture as property drawers at the time of filing a note. I now have to choose to either go the org-roam-ql way and subset notes via title/tag/backlink or do a full text search (i.e. via deft). The possibility of combining the two would help tremendously.

@ahmed-shariff
Copy link
Owner

Thank you very much for the comments.

org-roam doesn't store the contents of the files themselves. At that point, it would just duplicate everything in the org files. And I couldn't find a good solution that is not too opinionated. Which is why it wasn't added as an option to org-roam-ql.

That being said, you should be able to add your own expansion function with org-roam-ql-defexpansion. org-roam-ql-defpred won't be suitable for this as reading through all nodes is not the most efficient. For example, I have the following which uses ripgrep:

  (org-roam-ql-defexpansion 'regexp-rg
                            "Regex on all org files."
                            (lambda (regexp)
                              (-map
                               #'org-roam-node-from-id
                               (-non-nil (--map
                                          ;; on windows the path has a colon, hence making it relative then expanding again.
                                          (pcase-let ((`(,file ,line ,match) (s-split ":" (f-relative it org-roam-directory))))
                                            (org-roam-with-file (expand-file-name file org-roam-directory) nil
                                              (goto-line (string-to-number line))
                                              (or (org-id-get-closest)
                                                  (progn
                                                    (goto-char (point-min))
                                                    (org-id-get)))))
                                          (--filter
                                           (< 0 (length it))
                                           (s-split "\n"
                                                    (with-temp-buffer
                                                      (call-process "rg" nil t "--null"
                                                                    "--line-buffered"
                                                                    "--color=never"
                                                                    "--max-columns=1000"
                                                                    "--path-separator" "/"
                                                                    "--smart-case"
                                                                    "--no-heading"
                                                                    "--with-filename"
                                                                    "--line-number"
                                                                    "--search-zip"
                                                                    "-j5"
                                                                    "-torg"
                                                                    regexp
                                                                    org-roam-directory)
                                                      (buffer-string)))))))))

Let me know if you have any other questions.

@claudiusmueller
Copy link
Author

Thank you for the quick response! I'll take a look and see how I can incorporate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants