# Read-only search interface for use by the web and NNTP interfaces
package PublicInbox::Search;
use strict;
-use warnings;
# values for searching
-use constant TS => 0; # Received: header in Unix time
-use constant YYYYMMDD => 1; # Date: header for searching in the WWW UI
-use constant DT => 2; # Date: YYYYMMDDHHMMSS
+use constant {
+ TS => 0, # Received: header in Unix time (IMAP INTERNALDATE)
+ YYYYMMDD => 1, # Date: header for searching in the WWW UI
+ DT => 2, # Date: YYYYMMDDHHMMSS
+ BYTES => 3, # IMAP RFC822.SIZE
+ # TODO
+ # REPLYCNT => 4, # IMAP ANSWERED
+};
use PublicInbox::Smsg;
use PublicInbox::Over;
add_val($doc, PublicInbox::Search::YYYYMMDD(), $yyyymmdd);
my $dt = strftime('%Y%m%d%H%M%S', @ds);
add_val($doc, PublicInbox::Search::DT(), $dt);
+ add_val($doc, PublicInbox::Search::BYTES(), $smsg->{bytes});
my $tg = term_generator($self);
$tg->set_document($doc);
# v1 and tests only:
$smsg->populate($hdr, $self);
+ $smsg->{bytes} //= length($mime->as_string);
eval {
# order matters, overview stores every possible piece of
foreach my $m ($mset->items) {
my $smsg = $ro->{over_ro}->get_art($m->get_docid);
like($smsg->{to}, qr/\blist\@example\.com\b/, 'to appears');
+ my $doc = $m->get_document;
+ my $col = PublicInbox::Search::BYTES();
+ my $bytes = PublicInbox::Smsg::get_val($doc, $col);
+ like($bytes, qr/\A[0-9]+\z/, '$bytes stored as digit');
+ ok($bytes > 0, '$bytes is > 0');
+ is($bytes, $smsg->{bytes}, 'bytes Xapian value matches Over');
}
$mset = $ro->query('tc:list@example.com', {mset => 1});