about summary refs log tree commit homepage
path: root/lib/PublicInbox/Search.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-09-02 11:04:16 +0000
committerEric Wong <e@80x24.org>2020-09-03 20:11:03 +0000
commit80b887f29b2ec71d025b4c266a1c26314758994c (patch)
tree31f9937daf20c21b33c0407763bf2d6bd06d2f66 /lib/PublicInbox/Search.pm
parent851aa7183cf2b152d7ff187729bc896597d22fad (diff)
downloadpublic-inbox-80b887f29b2ec71d025b4c266a1c26314758994c.tar.gz
search: replace ->query with ->mset
Nearly all of the search uses in the production code rely on
a Xapian mset iterator being returned (instead of an array
of $smsg objects).  So default to returning the mset and move
the burden of smsg array conversion into the test cases.
Diffstat (limited to 'lib/PublicInbox/Search.pm')
-rw-r--r--lib/PublicInbox/Search.pm12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index 546884a9..cfa942b2 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -279,7 +279,7 @@ sub reopen {
 }
 
 # read-only
-sub query {
+sub mset {
         my ($self, $query_string, $opts) = @_;
         $opts ||= {};
         my $qp = $self->{qp} //= qparse_new($self);
@@ -346,17 +346,17 @@ sub _enquire_once { # retry_reopen callback
         if ($opts->{thread} && has_threadid($self)) {
                 $enquire->set_collapse_key(THREADID);
         }
+        $enquire->get_mset($opts->{offset} || 0, $opts->{limit} || 50);
+}
 
-        my $offset = $opts->{offset} || 0;
-        my $limit = $opts->{limit} || 50;
-        my $mset = $enquire->get_mset($offset, $limit);
-        return $mset if $opts->{mset};
+sub mset_to_smsg {
+        my ($self, $ibx, $mset) = @_;
         my $nshard = $self->{nshard} // 1;
         my $i = 0;
         my %order = map { mdocid($nshard, $_) => ++$i } $mset->items;
         my @msgs = sort {
                 $order{$a->{num}} <=> $order{$b->{num}}
-        } @{$self->{over_ro}->get_all(keys %order)};
+        } @{$ibx->over->get_all(keys %order)};
         wantarray ? ($mset->get_matches_estimated, \@msgs) : \@msgs;
 }