From 64b557420689476493d752968d99ab8ae62bad9a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 13 Mar 2021 15:40:27 +0000 Subject: searchidx: fix -Lmedium for IDs and filenames This fixes "m:", "l:", "f:", "t:", "c:", "dfn:", and "n:" search prefixes under indexlevel=medium when mixed with indexlevel=full inboxish. We need positional data for Message-IDs, List-Id, email addresses and filenames for exact matches, though we still want to support wildcards. Fortunately the storage cost is still small as these prefixes tend to be small compared to message bodies. These are NOT boolean terms since wildcard support and partial matching is desired. --- t/lei_xsearch.t | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 't') diff --git a/t/lei_xsearch.t b/t/lei_xsearch.t index f865ff43..5bfbcfe6 100644 --- a/t/lei_xsearch.t +++ b/t/lei_xsearch.t @@ -78,4 +78,35 @@ is(scalar(@ibxish), scalar(@ibx) + 1, 'got locals back'); is($lxs->search, $lxs, '->search works'); is($lxs->over, undef, '->over fails'); +{ + $lxs = PublicInbox::LeiXSearch->new; + my $v2ibx = PublicInbox::InboxWritable->new({ + inboxdir => "$home/v2full", + name => 'v2full', + version => 2, + indexlevel => 'full', + -primary_address => 'v2full@example.com', + }, {}); + my $im = $v2ibx->importer(0); + $im->add(eml_load('t/plack-qp.eml')); + $im->done; + my $v1ibx = PublicInbox::InboxWritable->new({ + inboxdir => "$home/v1medium", + name => 'v1medium', + version => 1, + indexlevel => 'medium', + -primary_address => 'v1medium@example.com', + }, {}); + $im = $v1ibx->importer(0); + $im->add(eml_load('t/utf8.eml')); + $im->done; + $lxs->prepare_external($v1ibx); + $lxs->prepare_external($v2ibx); + for my $loc ($lxs->locals) { + $lxs->attach_external($loc); + } + my $mset = $lxs->mset('m:testmessage@example.com'); + is($mset->size, 1, 'got m: match on medium+full XSearch mix'); +} + done_testing; -- cgit v1.2.3-24-ge0c7