[Xapian-discuss] query within value range

Mark Clarkson mark.clarkson at smorg.co.uk
Mon Jun 18 19:13:38 BST 2007


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. 

The Value Range Processor really is very neat.
I can now search for things between two times, with 1 second resolution.
Try doing that with boolean terms!

I added two lines to my search code:

  DateValueRangeProcessor d(0);
  qp.add_valuerangeprocessor(&d);

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?

Cheers
Mark.




More information about the Xapian-discuss mailing list