[Xapian-discuss] Creating a nice description of user supplied search terms

Olly Betts olly at survex.com
Fri May 11 22:50:48 BST 2007


On Fri, May 11, 2007 at 01:13:11PM -0700, Matt Barnicle wrote:
> How could I go about creating a nice textual description of what the 
> user searched for in the paged results?  Say for example they search for 
> banana orange, and I wanted to tell them, "Your search for banana OR 
> orange produced:", also supporting phrase searching, e.g. "banana cream 
> pie" orange would say "Your search for 'banana cream pie' OR orange 
> produced:".  I tried out the $query->get_description() method but the 
> description is cryptic for casual users.

Indeed, it's really intended for debugging purposes.

> What do u think, am I chasing a pipe dream?

It certainly seems a reasonable thing to want to be able to implement,
but I'm not sure it's too easy at the moment.  The only way to do it
outside the library is to parse the output of Query::get_description()
which isn't really a good approach, not least since it's not intended
to be parsable, and could even be ambiguous.

It would be rather easier to implement inside the Xapian library I
think, as you have access to the information you need there.  The only
thing to beware of is that some query rearrangement/simplification can
happen as a query is constructed.  The main one is that lots of
pair-wise ANDs or ORs are turned into a group AND or OR, and in fact
this one is likely to help you to produce a better description.  But
it's something to bear in mind.

The other approach would be to provide an API which exposes the
information required to implement this externally, but I'm not sure
quite how that might work off the top of my head...

Cheers,
    Olly



More information about the Xapian-discuss mailing list