From: Eric Wong Date: Sat, 10 Aug 2024 09:00:05 +0000 (+0000) Subject: search: move QueryParser mappings to xh_args X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67d843d15ba5b22a385ed71b6ce744cba4c393b0;p=thirdparty%2Fpublic-inbox.git search: move QueryParser mappings to xh_args These are stable per-search instance. We'll also deduplicate the strings in case multiple inboxes share the same mappings. --- diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index bdf5591cd..dfe0271b9 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -476,16 +476,7 @@ sub xh_opt ($$) { push @ret, '-t' if $opt->{threads}; push @ret, '-T', $opt->{threadid} if defined $opt->{threadid}; push @ret, '-O', $opt->{eidx_key} if defined $opt->{eidx_key}; - my $apfx = $self->{-alt_pfx} //= do { - my @tmp; - for my $x (@{$self->{-extra} // []}) { - my $sym = $QPMETHOD_2_SYM{$x->query_parser_method}; - push @tmp, '-Q', $x->{prefix}.$sym.$x->{xprefix}; - } - # TODO: arbitrary header indexing goes here - \@tmp; - }; - (@ret, @$apfx); + @ret; } # returns a true value if actually handled asynchronously, @@ -730,7 +721,17 @@ sub all_terms { } sub xh_args { # prep getopt args to feed to xap_helper.h socket - map { ('-d', $_) } shard_dirs($_[0]); + my ($self) = @_; + my $apfx = $self->{-alt_pfx} //= do { + my %dedupe; + for my $x (@{$self->{-extra} // []}) { + my $sym = $QPMETHOD_2_SYM{$x->query_parser_method}; + $dedupe{$x->{prefix}.$sym.$x->{xprefix}} = undef; + } + # TODO: arbitrary header indexing goes here + [ sort keys %dedupe ]; + }; + ((map { ('-d', $_) } shard_dirs($self)), map { ('-Q', $_) } @$apfx); } sub docids_by_postlist ($$) { diff --git a/t/watch_indexheader.t b/t/watch_indexheader.t index e815fca96..623698e73 100644 --- a/t/watch_indexheader.t +++ b/t/watch_indexheader.t @@ -84,7 +84,7 @@ $cfg->each_inbox(sub { my $eml = $ibx->smsg_eml($ibx->over->get_art($num->[0])); is($eml->header_raw('X-Archives-Hash'), $h1, 'stored message with X-Archives-Hash'); - my @opt = $srch->xh_opt; + my @opt = $srch->xh_args; is $opt[-2], '-Q', 'xap_helper -Q switch'; is $opt[-1], 'xarchiveshash=XXARCHIVESHASH', 'xap_helper -Q arg'; });