~swalladge/searchr

Command line tool for plain text file indexing and searching

Casper Meijn via public-inbox

2 months ago
2 months ago

#Searchr

A simple command line full text search engine for your local plain text files.

#Installation

Standard rust project. Git clone and cargo build should work fine. It's also available on crates.io as searchr.

If you run Archlinux, you can install from the aur: searchr-git.

#Usage

  1. Create a config file to configure what files you want indexed and where to store the indexes. (see configuration section below)
  2. Create the index: mkdir <my index location> && searchr index
  3. Search: searchr search "foo bar"

See tantivy docs for the supported query syntax.

#Configuration

See example_config.toml for an example. The software searches for the configuration file in the following locations in order, and uses the first match:

  1. path passed to -c on the command line
  2. $XDG_CONFIG_HOME/searchr/config.toml
  3. $HOME/.config/searchr/config.toml

If none are found, the software exits with an error.

#Contributing

Please send your comments, bug reports, feature requests, and patches to this public mailing list: ~swalladge/public-inbox@lists.sr.ht (archives).

#Notes

  • builds indexes and searches with tantivy. This also means that other tantivy-based tools can be used on the indexes, like tantivy-cli.

#Why?

My note taking workflow involves a large number of plain text files loosely inspired by Zettelkasten and vimwiki. Since I generally avoid categories and hierarchies, various types of searches is the main method I use for finding a note. Currently there are two methods I use for finding a note:

  1. fuzzy text search on the note filenames (fzf
  2. grep through the files

The first method is perfect if I roughly know what what I'm looking for and know there's a note with that in the title. The second is great if I'm looking for a specific pattern or word. What's missing though is a general full text content search. Grepping doesn't work so well when you're looking for a set of keywords. So that's where this tool comes in! Now I have a third method for searching my notes that sits between a fuzzy title search and specific regex searches.

There are other full text search engines around, but so far I haven't found something that is small and simple. I wanted something that I could configure and set up by nothing more than editing a short config file and running a single command.

#License

Copyright © 2019-2021 Samuel Walladge

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.