From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C70AC1FBCF for ; Wed, 10 Jun 2020 07:07:29 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 56/82] search: index UID for IMAP search, too Date: Wed, 10 Jun 2020 07:04:53 +0000 Message-Id: <20200610070519.18252-57-e@yhbt.net> In-Reply-To: <20200610070519.18252-1-e@yhbt.net> References: <20200610070519.18252-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We'll need to support searching UID ranges for IMAP, so make sure it's indexed, too. --- lib/PublicInbox/Search.pm | 1 + lib/PublicInbox/SearchIdx.pm | 1 + t/search.t | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index f2d3b92dc82..c54cf7b9911 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -12,6 +12,7 @@ use constant { YYYYMMDD => 1, # Date: header for searching in the WWW UI DT => 2, # Date: YYYYMMDDHHMMSS BYTES => 3, # IMAP RFC822.SIZE + UID => 4, # IMAP UID == NNTP article number == Xapian docid # TODO # REPLYCNT => 4, # IMAP ANSWERED }; diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index f7462aa74ca..3df7970ebf9 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -342,6 +342,7 @@ sub add_xapian ($$$$) { 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}); + add_val($doc, PublicInbox::Search::UID(), $smsg->{num}); my $tg = term_generator($self); $tg->set_document($doc); diff --git a/t/search.t b/t/search.t index cf3254169ca..d4ca28c794f 100644 --- a/t/search.t +++ b/t/search.t @@ -324,6 +324,11 @@ $ibx->with_umask(sub { 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'); + + $col = PublicInbox::Search::UID(); + my $uid = PublicInbox::Smsg::get_val($doc, $col); + is($uid, $smsg->{num}, 'UID column matches {num}'); + is($uid, $m->get_docid, 'UID column matches docid'); } $mset = $ro->query('tc:list@example.com', {mset => 1});