about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/PublicInbox/Search.pm12
-rw-r--r--lib/PublicInbox/SearchIdx.pm2
-rw-r--r--t/search.t6
3 files changed, 16 insertions, 4 deletions
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index cb669e87..f2d3b92d 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -5,12 +5,16 @@
 # 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;
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index f4fa50ff..f7462aa7 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -341,6 +341,7 @@ sub add_xapian ($$$$) {
         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);
@@ -388,6 +389,7 @@ sub add_message {
 
         # v1 and tests only:
         $smsg->populate($hdr, $self);
+        $smsg->{bytes} //= length($mime->as_string);
 
         eval {
                 # order matters, overview stores every possible piece of
diff --git a/t/search.t b/t/search.t
index 6cf2bc2d..cf325416 100644
--- a/t/search.t
+++ b/t/search.t
@@ -318,6 +318,12 @@ $ibx->with_umask(sub {
         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});