[Xapian-discuss] Usage of DateRangeValueProcessor

Olly Betts olly at survex.com
Wed Jul 13 04:40:38 BST 2011


On Mon, Jul 11, 2011 at 09:37:10PM +0200, Arjen Smedes wrote:
> After some ample trying and checking code, I'm stuck again. I can't get the
> daterangevalue stuff to work. Here are some snippets of my problem:
> 
> 1. class PortCallIndexer(Indexer):
>     fields = [
>         'estimated_date_of_arrival',
>     ]
> 
>     tags = [
>         ('eta', 'estimated_date_of_arrival'),
>     ]
> 
>     def _get_query_parser(self, *args, **kwargs):
> 
>         query_parser = Indexer._get_query_parser(self, *args, **kwargs)
>         query_parser.add_valuerangeprocessor(DateValueRangeProcessor(8,
> "eta:"))
> 
>         return query_parser
> 
> 2. some delve output:
> 
> Term List for record #1: 00 06 07 111 2011 4 CRN4 ETA00 ETA06 ETA07 ETA2011
> SHIP111 SHIPwe UID-6-pm.PortCall-pm.index.portcallindexer we

A ValueRangeProcessor uses document values (hence the name), so the term
list isn't relevant here.  During indexing, are you adding dates for
each document in value slot 8 with the format YYYYMMDD (e.g. 20110713)?
i.e. code like:

    doc.add_value(8, date_as_yyyymmdd);

You can inspect this with delve:

delve /path/to/db -V8 -1|head

> 3. I'd like to use the index to search for date-ranges. For examples, all
> entries between 2011/06/01..2011/08/01, but I have tried a number of search
> queries, none gives me what I need:
> 
> eta:2011/06/01..2011/08/04

This should work.  Look at query.get_description() to check this is
parsed as a value range.

> eta:2011/06/01

This isn't a range (no '..').

On Mon, Jul 11, 2011 at 09:51:37PM +0200, Arjen Smedes wrote:
> Some quest command I've been trying as well, no results either:
> 
> quest -d /var/tmp/djapian_spaces/pm/portcall/pm.index.portcallindexer/
> -p=eta "2011/06/01..2011/07/01"

As written, that should give an error:

quest: need ':' when setting prefix

But anyway, -p sets up a term prefix, which is nothing to do with value
ranges, so this isn't going to do what you're hoping.  You can't
configure value ranges using quest's command line options.

> whereas
> 
> quest -d /var/tmp/djapian_spaces/pm/portcall/pm.index.portcallindexer/
> -p=eta: "2011/06/01"
> Parsed Query: Xapian::Query((2011:(pos=1) PHRASE 3 06:(pos=2) PHRASE 3
> 01:(pos=3)))

This is just a phrase search for: "2011 06 01".

Cheers,
    Olly



More information about the Xapian-discuss mailing list