Enrico Zini Enrico Zini http://www.enricozini.org/ Enrico Zini ikiwiki 2010-04-09T22:23:18Z apt-xapian-index now comes with a query tool http://www.enricozini.org/2010/debian/axi-cache/ 2010-04-09T22:23:18Z 2010-04-09T22:23:18Z <h1>apt-xapian-index now comes with a query tool</h1> <p>I've just uploaded a new version of <a href="http://www.enricozini.org/./2007/debtags/apt-xapian-index/">apt-xapian-index</a> to unstable. Now it comes with a little query tool called <em>axi-cache</em>.</p> <p>You can search this way:</p> <pre><code>axi-cache search foo bar baz facet::tag sec:section </code></pre> <p>In fact, you can use most of the things described <a href="http://xapian.org/docs/queryparser.html">here</a>.</p> <p>You can then say <code>axi-cache more</code> to get more results, or <code>axi-cache again</code> to retry a search, or <code>axi-cache again wibble wabble</code> to add keywords to the last search.</p> <p>This allows to start with a search and tweak it. In order to work it needs to save the last search so <code>again</code> or <code>more</code> can amend it. Searches are saved in <code>~/.cache/axi-cache.state</code>.</p> <p>You can search tags instead of packages by adding <code>--tags</code>.</p> <p>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 <code>update-apt-xapian-index</code>.</p> <p>I need to thank <a href="http://cworth.org/~cworth/">Carl Worth</a> who, with <a href="http://notmuchmail.org/">notmuch</a>, reminded me that if I just build a nice interface on top of Xapian's <a href="http://xapian.org/docs/queryparser.html">query parser</a> I go quite a long way towards making a <a href="http://xapian.org">Xapian</a> database extremely useful indeed.</p> <p><code>axi-cache</code> also integrates with bash-completion so that tab completion is context-sensitive to the command line <em>being typed</em>:</p> <pre><code>&#036; axi-cache search image pro probability process processors programmability provides problem processing production pronounced proving &#036; axi-cache search kernel pro problems processor production proved provided processing processors programming provide provides </code></pre> <p>Thanks to David Paleino who wrote the bash completion script.</p> <p>Just for reference, this is the command line help:</p> <pre><code>&#036; 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') </code></pre> <p>If you install the package for the first time, you may need to rebuild the index by running <code>update-apt-xapian-index</code> as root before using axi-cache.</p>