Creating and using multiple indexes

Why would you want to do this ?

  • Easy adjustment of search areas: you can filter results by using the directory filter in the advanced search panel, but, if you have separate well defined places where you store different kind of data, it is easier to maintain separate index and use the External indexes dialog to switch them on or off, and it will also yield much better search performance.

  • Shared indexes: it may be useful to maintain one or several indexes for shared data, and separate personal indexes for each user. Indexes can be shared over the network.

  • Creating separate indexes for removable volumes.

How to do it

As an example we’ll suppose that you have Recoll installed and indexing your home directory, and that you would like to have a separate index for /usr/share/doc.

You need to create a separate configuration for the new index, then add it to the external indexes list in the user interface, and activate it as needed.

  1. Create a directory for the new index, and create an empty configuration file

    mkdir .recoll-sharedoc
    touch .recoll-sharedoc/recoll.conf
  2. Either edit the new configuration by hand or start recoll to use the GUI configuration editor.

    cd .recoll-sharedoc
    echo "topdirs = /usr/share/doc" > recoll.conf
    # OR
    recoll -c ~/.recoll-sharedoc

    If using the GUI, click Cancel when asked, to start the configuration editor.

  3. Perform initial indexing. If you chose the GUI route, indexing will start as soon as you leave the configuration editor. Else, on the command line:

    recollindex -c ~/.recoll-sharedoc
  4. Optionally set up cron to perform nightly indexing, use crontab -e and insert a line like the following:

    45 20 * * * recollindex -c ~/.recoll-sharedoc

    This would start the indexing at 20:45. crontab -e will use the vi editor by default, you can change this by using the EDITOR environment variable. Exemple: EDITOR=kate crontab -e Your favorite desktop may also have a dedicated tool to add crontab entries.

  5. Start recoll and choose the Preferences→External index dialog menu entry, then click the Browse button (near the bottom), and select the new index Xapian database directory ~/.recoll-sharedoc/xapiandb Then click Add index.

  6. You can then activate or deactivate the new index by clicking the box in front of the directory name in the list.

When adding an index shared by multiple users, it may be helpful to use the RECOLL_EXTRA_DBS environment variable instead of editing individual configurations, see the manual for more details.

Paths adjustments

When sharing indexes over a network, in most cases, the indexed data will be accessible through different paths on the different hosts. This will prevent the Preview and Open functions to work because the paths they get from the index do not match the ones which are usable from the local host.

For example my home directory is accessed as /home/me on my home machine, and as /net/myhost/home/me on other hosts. By default, trying to access a result from a remote host would use the first path, when the second is the one that would work.

As of release 1.19 Recoll has a facility to perform index-dependant path translations. This facility is accessible from the external index dialog in the GUI preferences. Paths translations can be set for the main index if no index is selected (rarely useful), or for the selected additional index. See the manual for more detail.