about summary refs log tree commit homepage
path: root/lib/PublicInbox/SearchView.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-05-21 23:22:05 +0000
committerEric Wong <e@80x24.org>2019-05-21 23:22:05 +0000
commite220b8b2ee5cfd458167dc2c6c92726352c4c80e (patch)
tree367fea0f8e7b2e23a313cccca1b2dac604e166b8 /lib/PublicInbox/SearchView.pm
parent1cb0e9b176774e3ff5e2397f4a1452bb2517454f (diff)
parentd0e8bfd866ed1e924e8d9f551939eecbea4920ef (diff)
downloadpublic-inbox-e220b8b2ee5cfd458167dc2c6c92726352c4c80e.tar.gz
* origin/xap-optional:
  admin: improve warnings and errors for missing modules
  searchidx: do not create empty Xapian partitions for basic
  lazy load Xapian and make it optional for v2
  www: use Inbox->over where appropriate
  nntp: use Inbox->over directly
  inbox: add ->over method to ease access
Diffstat (limited to 'lib/PublicInbox/SearchView.pm')
-rw-r--r--lib/PublicInbox/SearchView.pm13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index 3b3afdee..6592b3b2 100644
--- a/lib/PublicInbox/SearchView.pm
+++ b/lib/PublicInbox/SearchView.pm
@@ -29,6 +29,8 @@ sub mbox_results {
 
 sub sres_top_html {
         my ($ctx) = @_;
+        my $srch = $ctx->{-inbox}->search or
+                return PublicInbox::WWW::need($ctx, 'Search');
         my $q = PublicInbox::SearchQuery->new($ctx->{qp});
         my $x = $q->{x};
         my $query = $q->{'q'};
@@ -44,7 +46,7 @@ sub sres_top_html {
         my ($mset, $total, $err, $cb);
 retry:
         eval {
-                $mset = $ctx->{srch}->query($query, $opts);
+                $mset = $srch->query($query, $opts);
                 $total = $mset->get_matches_estimated;
         };
         $err = $@;
@@ -98,8 +100,8 @@ sub mset_summary {
         my $pad = length("$total");
         my $pfx = ' ' x $pad;
         my $res = \($ctx->{-html_tip});
-        my $srch = $ctx->{srch};
         my $ibx = $ctx->{-inbox};
+        my $srch = $ibx->search;
         my $obfs_ibx = $ibx->{obfuscate} ? $ibx : undef;
         foreach my $m ($mset->items) {
                 my $rank = sprintf("%${pad}d", $m->get_rank + 1);
@@ -220,8 +222,8 @@ sub sort_relevance {
 sub mset_thread {
         my ($ctx, $mset, $q) = @_;
         my %pct;
-        my $srch = $ctx->{srch};
-        my $msgs = $srch->retry_reopen(sub { [ map {
+        my $ibx = $ctx->{-inbox};
+        my $msgs = $ibx->search->retry_reopen(sub { [ map {
                 my $i = $_;
                 my $smsg = PublicInbox::SearchMsg->load_doc($i->get_document);
                 $pct{$smsg->mid} = $i->get_percent;
@@ -232,7 +234,6 @@ sub mset_thread {
                 $r ? sort_relevance(\%pct) : *PublicInbox::View::sort_ds,
                 $ctx);
         my $skel = search_nav_bot($mset, $q). "<pre>";
-        my $ibx = $ctx->{-inbox};
         $ctx->{-upfx} = '';
         $ctx->{anchor_idx} = 1;
         $ctx->{cur_level} = 0;
@@ -286,7 +287,7 @@ sub adump {
         my $ibx = $ctx->{-inbox};
         my @items = $mset->items;
         $ctx->{search_query} = $q;
-        my $srch = $ctx->{srch};
+        my $srch = $ibx->search;
         PublicInbox::WwwAtomStream->response($ctx, 200, sub {
                 while (my $x = shift @items) {
                         $x = load_doc_retry($srch, $x);