#!perl -w
-# Copyright (C) 2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use v5.10.1;
use Test::More;
use List::Util qw(shuffle max);
use PublicInbox::TestCommon;
-use PublicInbox::ExtSearchIdx;
use PublicInbox::Eml;
use PublicInbox::InboxWritable;
require_mods(qw(DBD::SQLite Search::Xapian));
+require PublicInbox::ExtSearchIdx;
require_git 2.6;
require_ok 'PublicInbox::LeiXSearch';
my ($home, $for_destroy) = tmpdir();
my $es = PublicInbox::ExtSearch->new("$home/eidx");
my $lxs = PublicInbox::LeiXSearch->new;
for my $ibxish (shuffle($es, @ibx)) {
- $lxs->attach_extinbox($ibxish);
+ $lxs->prepare_external($ibxish);
+}
+for my $loc ($lxs->locals) {
+ $lxs->attach_external($loc);
}
my $nr = $lxs->xdb->get_doccount;
my $mset = $lxs->mset('d:19931002..19931003', { limit => $nr });
is($lxs->smsg_for(($mset->items)[0])->{docid}, $max,
'got highest docid');
+my @ibxish = $lxs->locals;
+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;