Enrico Zini: axi-query-pkgtype
apt-xapian-index: adding simple result filters to the query
I've recently posted an introduction of apt-xapian-index and an example of how to query it.
Today I'll show how to add simple Debtags-based result filters to a query.
I'll expand axi-query-simple.py
with a
It's now trivial to lookup a query and AND it to the main query:
That's it. Simple, trivial feature to add to a search, but very useful and
simple to use.
You can use the wsvn interface to get to the full source code and the module it uses. Try running it as:
--type comman line option that allows to filter for package type. As
a starter I'll implement filtering for "game", "gui", "cmdline" or "editor".
If you feel like reimplementing my examples in another language, let me know
and I'll include it to the post.
The filters are implemented using Xapian queries. Xapian allows to build
queries as well as combine existing queries using a large amount of
operators.
This allows us to create a little database of ready made queries:
# This is our little database of simple Debtags filters we provide: the name # entered by the user in "--type" maps to a piece of Xapian query filterdb = dict( # We can do simple AND queries... game = xapian.Query(xapian.Query.OP_AND, ('XTuse::gameplaying', 'XTrole::program')), # Or we can do complicate binary expressions... gui = xapian.Query(xapian.Query.OP_AND, xapian.Query('XTrole::program'), xapian.Query(xapian.Query.OP_OR, 'XTinterface::x11', 'XTinterface::3d')), cmdline = xapian.Query(xapian.Query.OP_AND, 'XTrole::program', 'XTinterface::commandline'), editor = xapian.Query(xapian.Query.OP_AND, 'XTrole::program', 'XTuse::editing')) # Feel free to invent more
# Build the query by ORing together various terms query = xapian.Query(xapian.Query.OP_OR, termlist) # If a filter was requested, AND it with the query if extrafilter: query = xapian.Query(xapian.Query.OP_AND, query, filterdb[extrafilter])
axi-query-pkgtype.py --type=gui image editor
axi-query-pkgtype.py --type=cmdline image editor
axi-query-pkgtype.py --type=game image editor
you will see that the results change radically.
What are the games that match "image editor", you would ask?
74% xjig - An X11 jigsaw puzzle
69% wmpuzzle - WindowMaker dock app 4x4 puzzle
66% xflip - programs to mirror-image or melt your display
Jigsaws, of course :)
The code is now colourised thanks to Simon Ward who pointed me at the syntax
plugin for ikiwiki.
Next in the series: suggesting new terms for improving the query.
As you can see in the picture I first executed one command on both
hosts, by typing it into the CSSH window, and then selected one host
directly, typing a command only this host sees.
Now, we are all lazy, so lets make cssh easier to use. Noone wants to
type hundreds of hostnames all the time. Luckily clusterssh has a
concept where you map tags to servernames. If you are the admin of your
machine and want to setup such a mapping for all of your users you edit
/etc/clusters, if you just want to do it for yourself edit
$HOME/.csshrc. Actually - do not edit it, but run

So
The last five days I've spent at the combined Debian Edu, FAI and CDD meeting in
Alright, a bit late. But it was hell of a concert, really enjoyed it. There were two support bands: First there was
It is interesting that there have been posts about archive tools appearing upon the
Sometime in August,
Great final. South Africa *and* England showed that a match without tries
can still be one of the best of the tournament.
The first half was one of the most intense (I'd say *the* most intense) I've
seen, with England playing well with their strengths (forward lanes, mauls)
but felt against a tremendously defending South African team...and a perfect
Percy Montgomery transforming all penalty kicks, therefore converting RSA
domination.
I also noticed the incredible energy of Bryan Habana who "destroyed" Sackey
three times even if he weights many pounds less.
I think that all rugby fans enjoyed that final even without tries (again,
South Africa wins a world cup without scoring a try in final).
So, that's the end of 1.5 month of rugby crazyness. Dear readers who
survived until now, thank you for sharing my passion for that sport...et
rendez-vous pour le tournoi des 6 nations..:-)
Original post can be found