[Xapian-discuss] Less than, greater than?

James Aylett james-xapian at tartarus.org
Wed Feb 9 15:19:37 GMT 2005

On Wed, Feb 09, 2005 at 02:51:12PM +0000, John Wards wrote:

> > > To the list this time again...sorry James this time. Must pay attention
> > > when sending emails!
> > > 
> > > Can't spot this in the overview docs for omega. Can I have a boolean
> > > value called price and do a less than, greater than?
> > 
> > Hmm, a boolean value is just that: boolean. There's no "greater" or
> > "smaller" in boolean algebra.
> It was a bit of a long shot as I suppose.

You may be able to prune some obviously off values at search time
(rather than postprocessing). Omega uses this (rather extensively) for
date range searching.

What you might do is to assign "price zones" (probably based around
common ranges that people might want to search over), so:

XP0    $0 <= price < $50
XP1    $50 <= price < $100
XP2    $100 <= price < $200

Then a boolean list of (XP0, XP1) will give you everything under $100,
and you can postprocess to get rid of everything above $75 to get <=
$75. This may turn out more useful to you if you regularly want to
search for a small range of prices, but where the rest of your query
will match lots of things outside that price range. Obviously you
choose where to put the ranges yourself.

You can 'chain' multiple boolean terms to omega by space separating
them in the 'B' parameter. What happens is that boolean terms with the
same prefix (capital letters form the prefix, so 'XP' in the above
example) are combined using OR, with the groups of /different/
prefixes combined using AND (this is described in docs/overview.txt).

So if you had B='XP0 XP1 XL17' (XP as above, XL a location id), only
documents that had both XL17 and either one of XP0 and XP1 terms would
match (assuming suitable probabilistic stuff in the 'P' parameter to
match and rank the documents). In this case this would mean that only
documents (rows from the original SQL table) with XL (location id) 17
and which were under $100 in price would be returned.


  James Aylett                                                  xapian.org
  james at tartarus.org                               uncertaintydivision.org

More information about the Xapian-discuss mailing list