diff options
author | Eric Wong <e@80x24.org> | 2024-05-05 23:35:10 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2024-05-06 06:06:09 +0000 |
commit | 34709e6f0153bd92a117f542a7bfb76e7d289d2e (patch) | |
tree | 69fdfb6579344b941e7018373ca55623519c3fe1 /lib/PublicInbox/XapHelper.pm | |
parent | 7f3b57f4c1cbbb7ddfa41dde6d25276ee96d3fd4 (diff) | |
download | public-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.pm | 14 |
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); |