apt-xapian-index now comes with a query tool

I've just uploaded a new version of apt-xapian-index to unstable. Now it comes with a little query tool called axi-cache.

You can search this way:

axi-cache search foo bar baz facet::tag sec:section

In fact, you can use most of the things described here.

You can then say axi-cache more to get more results, or axi-cache again to retry a search, or axi-cache again wibble wabble to add keywords to the last search.

This allows to start with a search and tweak it. In order to work it needs to save the last search so again or more can amend it. Searches are saved in ~/.cache/axi-cache.state.

You can search tags instead of packages by adding --tags.

It will suggest extra terms for the search, and also suggest extra tags. It can even correct spelling mistakes in the query terms once the index has been rebuilt with this new version of update-apt-xapian-index.

I need to thank Carl Worth who, with notmuch, reminded me that if I just build a nice interface on top of Xapian's query parser I go quite a long way towards making a Xapian database extremely useful indeed.

axi-cache also integrates with bash-completion so that tab completion is context-sensitive to the command line being typed:

$ axi-cache search image pro
probability      process          processors       programmability  provides
problem          processing       production       pronounced       proving
$ axi-cache search kernel pro
problems     processor    production   proved       provided
processing   processors   programming  provide      provides

Thanks to David Paleino who wrote the bash completion script.

Just for reference, this is the command line help:

$ axi-cache help
Usage: axi-cache [options] command [args]

Query the Apt Xapian index.

Commands:
  axi-cache help            show a summary of commands
  axi-cache search [terms]  start a new search
  axi-cache again [query]   repeat the last search, possibly adding query terms
  axi-cache more [count]    show more terms from the last search

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -s SORT, --sort=SORT  sort by the given value, as listed in /var/lib/apt-
            xapian-index/values
  --tags                show matching tags, rather than packages
  --tabcomplete=TYPE    suggest words for tab completion of the current
            command line (type is 'plain' or 'partial')

If you install the package for the first time, you may need to rebuild the index by running update-apt-xapian-index as root before using axi-cache.