-# Copyright (C) 2015-2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2015-2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use warnings;
}
{
- my $crlf_adjust = \&PublicInbox::SearchIdx::crlf_adjust;
+ my $crlf_adjust = \&PublicInbox::Smsg::crlf_adjust;
is($crlf_adjust->("hi\r\nworld\r\n"), 0, 'no adjustment needed');
is($crlf_adjust->("hi\nworld\n"), 2, 'LF-only counts two CR');
is($crlf_adjust->("hi\r\nworld\n"), 1, 'CRLF/LF-mix 1 counts 1 CR');
like($smsg->{to}, qr/\blist\@example\.com\b/, 'to appears');
my $doc = $m->get_document;
my $col = PublicInbox::Search::BYTES();
- my $bytes = PublicInbox::SearchIdx::get_val($doc, $col);
+ my $bytes = PublicInbox::Search::int_val($doc, $col);
like($bytes, qr/\A[0-9]+\z/, '$bytes stored as digit');
ok($bytes > 0, '$bytes is > 0');
is($bytes, $smsg->{bytes}, 'bytes Xapian value matches Over');
$col = PublicInbox::Search::UID();
- my $uid = PublicInbox::SearchIdx::get_val($doc, $col);
+ my $uid = PublicInbox::Search::int_val($doc, $col);
is($uid, $smsg->{num}, 'UID column matches {num}');
is($uid, $m->get_docid, 'UID column matches docid');
-
- # check ->xref3 for external index:
- is_deeply($smsg->xref3($doc), [], 'xref3 empty by default');
- my $exp = "inbox.com.example:$uid:deadbeef";
- $doc->add_boolean_term('P'.$exp);
- is_deeply($smsg->xref3($doc), [ $exp ], 'xref3 can be set');
- $doc->remove_term('P'.$exp);
- is_deeply($smsg->xref3($doc), [], 'xref3 can be unset');
}
$mset = $ibx->search->mset('tc:list@example.com');
$rw_commit->();
my $doc_id = $rw->add_message(eml_load('t/data/message_embed.eml'));
ok($doc_id > 0, 'messages within messages');
-
- my $eml = PublicInbox::Eml->new(<<EOF);
-List-Id: <blahblah.example.com>
-
-EOF
- $rw->add_xref3($doc_id, 1, 'deadbeef', 'newsgroup1.example', $eml);
- $rw_commit->();
+ $rw->commit_txn_lazy;
+ $ibx->search->reopen;
my $n_test_eml = $query->('n:test.eml');
is(scalar(@$n_test_eml), 1, 'got a result');
my $n_embed2x_eml = $query->('n:embed2x.eml');
is($query->('s:"mail header experiments"')->[0]->{mid},
'20200418222508.GA13918@dcvr',
'Subject search reaches inside message/rfc822');
- is($query->('l:blahblah.example.com')->[0]->{num}, $doc_id,
- 'xref3 List-Id probabilistic works');
- is($query->('lid:blahblah.example.com')->[0]->{num}, $doc_id,
- 'xref3 List-Id boolean term works');
- $rw->remove_xref3($doc_id, 'deadbeef', 'newsgroup1.example', $eml);
- $rw->commit_txn_lazy;
- $ibx->search->reopen;
- my $res = $query->('lid:blahblah.example.com');
- is_deeply($res, [], '->remove_xref3 dropped boolean term');
});
done_testing();