[Xapian-discuss] query within value range

Olly Betts olly at survex.com
Tue Jun 19 14:04:02 BST 2007


On Mon, Jun 18, 2007 at 07:13:38PM +0100, Mark Clarkson wrote:
> On Tue, 2007-06-05 at 19:22 +0100, Olly Betts wrote:
> > just make your own ValueRangeProcessor subclass which does what you
> > want.  Or suggest a patch for DateValueRangeProcessor if it's possible
> > to cleanly extend it to handle your case. 
>
> My date values are stored in date/time format as YYYYMMDDHHMMSS, so I
> added this to the source:
> 
> --- valuerangeproc.cc.orig      2007-06-18 17:47:47.000000000 +0100
> +++ valuerangeproc.cc   2007-06-18 17:47:58.000000000 +0100
> @@ -77,6 +77,12 @@
>         // YYYYMMDD
>         return valno;
>      }
> +    if (begin.size() == 14 && end.size() == 14 &&
> +       begin.find_first_not_of("0123456789") == string::npos &&
> +       end.find_first_not_of("0123456789") == string::npos) {
> +       // YYYYMMDDHHMMSS
> +       return valno;
> +    }
>      if (begin.size() == 10 && end.size() == 10 &&
>         begin.find_first_not_of("0123456789") == 4 &&
>         end.find_first_not_of("0123456789") == 4 &&
> 
> And it just worked!
> 
> Any chance the above snippet could be included in the source?

Hmm, and it's OK to return different length date/time value bounds
because it's a string compare, so this will work whatever granularity
the values are in the database.

This seems reasonable to me.  My tree's quite heavily patched at the
moment, but I'll apply it before the next release.  If you could supply
a few test cases (for queryparsertest.cc) that would be useful.

Cheers,
    Olly



More information about the Xapian-discuss mailing list