This is similar to mairix in that it uses a "d:" prefix; but
only takes YYYYMMDD, for now. Using custom date/time parsers
via Perl will be much more work:
nntp://news.gmane.org/
20151005222157.GE5880@survex.com
Anyhow, this ought to be more human-friendly than searching by
Unix timestamps, but it requires reindexing to take advantage of.
use constant NUM => 1; # NNTP article number
use constant BYTES => 2; # :bytes as defined in RFC 3977
use constant LINES => 3; # :lines as defined in RFC 3977
+use constant YYYYMMDD => 4; # for searching in the WWW UI
use Search::Xapian qw/:standard/;
use PublicInbox::SearchMsg;
$qp->set_database($self->{xdb});
$qp->set_stemmer($self->stemmer);
$qp->set_stemming_strategy(STEM_SOME);
+ $qp->add_valuerangeprocessor(
+ Search::Xapian::StringValueRangeProcessor->new(YYYYMMDD, 'd:'));
while (my ($name, $prefix) = each %bool_pfx_external) {
$qp->add_boolean_prefix($name, $prefix);
use PublicInbox::MID qw/mid_clean id_compress mid_mime/;
use PublicInbox::MsgIter;
use Carp qw(croak);
+use POSIX qw(strftime);
require PublicInbox::Git;
*xpfx = *PublicInbox::Search::xpfx;
$doc->add_term(xpfx('path') . id_compress($path));
}
- add_val($doc, &PublicInbox::Search::TS, $smsg->ts);
+ my $ts = $smsg->ts;
+ add_val($doc, &PublicInbox::Search::TS, $ts);
defined($num) and
add_val($doc, &PublicInbox::Search::NUM, $num);
add_val($doc, &PublicInbox::Search::LINES,
$mime->body_raw =~ tr!\n!\n!);
+ my $yyyymmdd = strftime('%Y%m%d', gmtime($ts));
+ $doc->add_value(&PublicInbox::Search::YYYYMMDD, $yyyymmdd);
+
my $tg = $self->term_generator;
$tg->set_document($doc);
'UTF-8 subject preserved');
}
+{
+ my $res = $ro->query('d:19931002..20101002');
+ ok(scalar @{$res->{msgs}} > 0, 'got results within range');
+ $res = $ro->query('d:20101003..');
+ is(scalar @{$res->{msgs}}, 0, 'nothing after 20101003');
+ $res = $ro->query('d:..19931001');
+ is(scalar @{$res->{msgs}}, 0, 'nothing before 19931001');
+}
+
done_testing();
1;