From 80b887f29b2ec71d025b4c266a1c26314758994c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 2 Sep 2020 11:04:16 +0000 Subject: 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. --- lib/PublicInbox/Search.pm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/PublicInbox/Search.pm') 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; } -- cgit v1.2.3-24-ge0c7