Local full text index for a directory tree, a quicker alternative for grep -R

I have a large directory tree of source files. I want to search around all these files. My first instinct is to use grep -R or ack, but either way they just sequentially read all the files.

Is there some lightweight programme that I can install that will scan all the files once, build and index, and then at any later date I can search for certain words? That should be quicker than just doing loads of grep's. The files I want to search won't be changing, so I don't need something that will index files automatically.

I'm not looking for something that will scan all the files on my harddrive, and i want something locally that's easy to install and set up on a local desktop machine, for simple almost throwaway searching.

Bonus points if the software in the normal ubuntu repositories.

Ideally I want something that's as easy to use as this:

sudo aptitude install supersearch
cd /path/to/where/I/wanna/search
supersearch --make-index 
supersearch "foo bar"

Solution 1:

Sounds like you want Beagle. Its main purpose is as a comprehensive desktop search, but you can tell it to just look at the source tree you want to index.

Solution 2:

I believe Tracker is installed by default on Ubuntu. Do man trackerd and man tracker-search for more info.

From the trackerd man page:

By default, trackerd will index all files in a user’s home directory
(with the exception of hidden files). This can be overridden by speci‐
fying one or more directories to be indexed instead in the configura‐
tion file ($HOME/.config/tracker/tracker.cfg) and/or by using the
--include-dir option to specify other directories to be indexed.