- my $url = $pi_config->{"publicinbox.$list.url"};
- defined $url or next;
-
- $url =~ s!/+\z!!;
-
- # try to find the URL with Xapian to avoid forking
- if ($have_xap) {
- my $doc_id = eval {
- my $s = PublicInbox::Search->new($git_dir);
- $s->find_unique_doc_id('mid', $mid);
- };
- if ($@) {
- # xapian not configured for this repo
- } else {
- # maybe we found it!
- return r302($url, $mid) if (defined $doc_id);
-
- # no point in trying the fork fallback if we
- # know Xapian is up-to-date but missing the
- # message in the current repo
- next;
+ # try to find the URL with Msgmap to avoid forking
+ my $num = $mm->num_for($mid);
+ if (defined $num) {
+ push @found, $other;
+ } else {
+ # no point in trying the fork fallback if we
+ # know Xapian is up-to-date but missing the
+ # message in the current repo
+ push @ibx, $other;
+ }
+ });
+
+ return exact($ctx, \@found, $mid) if @found;
+
+ # fall back to partial MID matching
+ my $n_partial = 0;
+ my @partial;
+
+ if (my $mm = $cur->mm) {
+ my $tmp_mid = $mid;
+ my $res = $mm->mid_prefixes($tmp_mid, 100);
+ if ($res && scalar(@$res)) {
+ $n_partial += scalar(@$res);
+ push @partial, [ $cur, $res ];
+ # fixup common errors:
+ } elsif ($tmp_mid =~ s,/[tTf],,) {
+ $res = $mm->mid_prefixes($tmp_mid, 100);
+ if ($res && scalar(@$res)) {
+ $n_partial += scalar(@$res);
+ push @partial, [ $cur, $res ];