about summary refs log tree commit homepage
path: root/lib/PublicInbox/XapHelper.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2024-05-05 23:35:10 +0000
committerEric Wong <e@80x24.org>2024-05-06 06:06:09 +0000
commit34709e6f0153bd92a117f542a7bfb76e7d289d2e (patch)
tree69fdfb6579344b941e7018373ca55623519c3fe1 /lib/PublicInbox/XapHelper.pm
parent7f3b57f4c1cbbb7ddfa41dde6d25276ee96d3fd4 (diff)
downloadpublic-inbox-34709e6f0153bd92a117f542a7bfb76e7d289d2e.tar.gz
External Xapian helper processes need to support non-standard
QueryParser prefixes.  The only way to do this is to specify
these prefixes in every `mset' request since we have no idea
if the XH worker servicing the request has initialized the
extra prefixes, yet.
Diffstat (limited to 'lib/PublicInbox/XapHelper.pm')
-rw-r--r--lib/PublicInbox/XapHelper.pm14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/PublicInbox/XapHelper.pm b/lib/PublicInbox/XapHelper.pm
index 2e20660e..099bc4fe 100644
--- a/lib/PublicInbox/XapHelper.pm
+++ b/lib/PublicInbox/XapHelper.pm
@@ -172,6 +172,18 @@ sub cmd_mset { # to be used by WWW + IMAP
         }
 }
 
+sub srch_init_extra ($) {
+        my ($req) = @_;
+        my $qp = $req->{srch}->{qp};
+        for (@{$req->{Q}}) {
+                my ($upfx, $m, $xpfx) = split /([:=])/;
+                $xpfx // die "E: bad -Q $_";
+                $m = $m eq '=' ? 'add_boolean_prefix' : 'add_prefix';
+                $qp->$m($upfx, $xpfx);
+        }
+        $req->{srch}->{qp_extra_done} = 1;
+}
+
 sub dispatch {
         my ($req, $cmd, @argv) = @_;
         my $fn = $req->can("cmd_$cmd") or return;
@@ -195,6 +207,8 @@ sub dispatch {
                 $new->{qp} = $new->qparse_new;
                 $new;
         };
+        $req->{Q} && !$req->{srch}->{qp_extra_done} and
+                srch_init_extra $req;
         my $timeo = $req->{K};
         alarm($timeo) if $timeo;
         $fn->($req, @argv);