[Xapian-discuss] custom ValueRangeProcessor in Perl?
Eric Wong
e at 80x24.org
Thu Sep 10 00:19:34 BST 2015
Hello, I'm using the XS Perl bindings packaged with Debian stable
and am interested in implementing my a custom ValueRangeProcessor
(using DateTimeX::Easy for human-friendly date parsing)
Unfortunately, I'm not sure if it's possible with the
add_valuerangeprocessor API via Perl.
Reading the XS/*ValueRangeProcessor.xs source files, I'm seeing
"process_value_range" methods being defined (but I can't figure out how
they're called); but attempting to define my own classes does not result
in the methods being called when performing a query.
I suppose I can workaround this by parsing the query string myself by
translating the dates with DateTimeX::Easy to Unix epochs which are
compatible with timestamp value field in my database for use with
NumericValueRangeProcessor.
Reading the source to sup (Ruby Xapian mail client[1]), it seems to do
this workaround (using the Chronic date parsing library).
Below are my attempts at making my own ValueRangeProcessor class.
Thanks in advance for any help or pointers you can provide.
Disclaimer: I am not knowledgeable in XS, SWIG, C++, or experienced
in using Xapian at all.
# Try #1 with subclassing NumberValueRangeProcessor:
package PublicInbox::Search::DateVRP1;
use strict; use warnings;
use base 'Search::Xapian::NumberValueRangeProcessor';
sub new {
my ($class, @args) = @_;
Search::Xapian::NumberValueRangeProcessor::new($class, @args);
}
# doesn't seem to get called
sub process_value_range {
use Data::Dumper; print STDERR "PVR called ", Dumper(\@_);
1;
}
1;
# Try 2 without subclassing
package PublicInbox::Search::DateVRP2;
use strict; use warnings;
sub new {
my ($class, @args) = @_;
my $s = 1;
bless \$s, $class;
}
# doesn't seem to get called
sub process_value_range {
use Data::Dumper; print STDERR "PVR called ", Dumper(\@_);
1;
}
1;
[1] - sup: git clone git://github.com/sup-heliotrope/sup.git
More information about the Xapian-discuss
mailing list