+sub mbox_all {
+ my ($ctx, $q) = @_;
+ my $q_string = $q->{'q'};
+ return mbox_all_ids($ctx) if $q_string !~ /\S/;
+ my $srch = $ctx->{ibx}->isrch or
+ return PublicInbox::WWW::need($ctx, 'Search');
+ my $over = $ctx->{ibx}->over or
+ return PublicInbox::WWW::need($ctx, 'Overview');
+
+ my $qopts = $ctx->{qopts} = { mset => 2 }; # order by docid
+ $qopts->{thread} = 1 if $q->{t};
+ my $mset = $srch->mset($q_string, $qopts);
+ $qopts->{offset} = $mset->size or
+ return [404, [qw(Content-Type text/plain)],
+ ["No results found\n"]];
+ $ctx->{query} = $q_string;
+ $ctx->{ids} = $srch->mset_to_artnums($mset, $qopts);
+ require PublicInbox::MboxGz;
+ my $fn;
+ if ($q->{t} && $srch->has_threadid) {
+ $fn = 'results-thread-'.$q_string;
+ PublicInbox::MboxGz::mbox_gz($ctx, \&results_thread_cb, $fn);
+ } else {
+ $fn = 'results-'.$q_string;
+ PublicInbox::MboxGz::mbox_gz($ctx, \&results_cb, $fn);
+ }