# "Smart Search" for Zettelkasten

The larger my zettelkasten becomes, the more the built-in search of The Archive does not give a good overview of the search results in any cases. Especially when I search for keywords which occur in a lot of zettels or that are very short (like e.g. "git") it takes me a while to find the right zettel. Well, compared to Niklas Luhmann it's still ligheting fast, but thats another story. ;-)

Searching is something I do a lot while working with my Zettelkasten. As I said before, title search is the feature I miss the most in The Archive.

On the other hand, I asked myself: would a combined search of title and content not even be better?

To check that out, I made a little Python script that I just pusblished on GitHub (for the first time, by the way – quite exiting!). This is the link:

https://github.com/ralfzosel/zk-smart-search

The installation chapter is quite short – probably too short, if you never used Python before. So if you want to check out my script (which would make me very happy) and if you have any trouble make it run, I am happy to assist.

• edited December 2022

@ralfzosel, this is deluxe and fast! Search is an area that needs a ton of attention. Your python program works silky smooth. I ran across only one possible area where some clarification might be wanted. export PATH=~/code/zk-smart-search:$PATH This assumes that the user would clone your repository to ~/code which assumes a lot. I didn't clone your repository to the code directory but a quick change and all is happy in the universe again. Putting the app zkss in the$PATH might be better explained.

Initially the code failed with the message:

➜  zk-smart-search git:(master) ✗ ./zkss forum ZettelDistraction
./zkss: line 3: cd: ~~/code/zk-smart-search: No such file or directory


## Here is the output of my first search!

Post edited by Will on

Will Simpson
The quality of our thinking is directly proportional to the quality of our reading. To think better, we must read better. - Rohan
kestrelcreek.com

• In the meantime , I have made some improvements and published a short demo video showing the "Zettelkasten Smart Search" in action. You find the clip on GitHub: https://github.com/ralfzosel/zk-smart-search

I am using the script every day and for me it already works very well. Therefore, I just felt like publishing a first (alpha) release.

• Great little update. Not having your script integrated into The Archive, so the results populate the "Note List," is a bit of a drawback. And having to keep the terminal open and transfer the note links from the terminal to The Archive is cumbersome.

Maybe @ctietze will expose the ability to populate the "Note List" with a custom list when he adds scriptability to The Archive. In the meantime, natively, you can sort search results by last modified, and you can use the OMNI Bar for "this term" and "that term" search and a "this and that term" search, but you can not do a title search in the Omni Bar. And you can not do the best thing that makes your little script handy: do them all at once.

Do you use Keyboard Maestro? If you do, I can show you how to place the results of your script in a variable and have Keyboard Maestro put the results in The Archive's note list, and then they can be selected easily.

I have a Keyboard Maestro macro that does a title search exclusively, and I developed a Keyboard Maestro macro that does a proximity search. ("this term" within X words of "that term"). Proximity Search in The Archive surfaces rich link candidates when creating new notes — Zettelkasten Forum

Searching is so vital to surfacing quality links.

One caveat to all this is that I place the title of the note, which is the filename, on the first line of every note, so when I search using the OMNI Bar, it will also be searching the filenames/titles. Just not exclusively.

Will Simpson
The quality of our thinking is directly proportional to the quality of our reading. To think better, we must read better. - Rohan
kestrelcreek.com