diff options
author | Eric Wong <e@80x24.org> | 2021-03-21 15:50:45 +0600 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-03-21 10:35:11 +0000 |
commit | 47d21e78be57a8f4615be5872e08ec4539423d1f (patch) | |
tree | aac2f06ea9c24b4a616702e849bcbaf024597dc5 /lib/PublicInbox/SearchIdx.pm | |
parent | 076543017b7646a7324156ed5d5245d467d53c1c (diff) | |
download | public-inbox-47d21e78be57a8f4615be5872e08ec4539423d1f.tar.gz |
Keyword storage for external-only messages was preventing messages from being explicitly imported. Teach lei_store to vivify keyword-only entries into fully-indexed messages on import.
Diffstat (limited to 'lib/PublicInbox/SearchIdx.pm')
-rw-r--r-- | lib/PublicInbox/SearchIdx.pm | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 3237aadc..3f933121 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -11,6 +11,7 @@ use strict; use v5.10.1; use parent qw(PublicInbox::Search PublicInbox::Lock Exporter); use PublicInbox::Eml; +use PublicInbox::Search qw(xap_terms); use PublicInbox::InboxWritable; use PublicInbox::MID qw(mids_for_index mids); use PublicInbox::MsgIter; @@ -34,6 +35,7 @@ use constant DEBUG => !!$ENV{DEBUG}; my $xapianlevels = qr/\A(?:full|medium)\z/; my $hex = '[a-f0-9]'; my $OID = $hex .'{40,}'; +my @VMD_MAP = (kw => 'K', label => 'L'); our $INDEXLEVELS = qr/\A(?:full|medium|basic)\z/; sub new { @@ -428,7 +430,15 @@ sub eml2doc ($$$;$) { sub add_xapian ($$$$) { my ($self, $eml, $smsg, $mids) = @_; begin_txn_lazy($self); + my $merge_vmd = delete $smsg->{-merge_vmd}; my $doc = eml2doc($self, $eml, $smsg, $mids); + if (my $old = $merge_vmd ? _get_doc($self, $smsg->{num}) : undef) { + my @x = @VMD_MAP; + while (my ($field, $pfx) = splice(@x, 0, 2)) { + my $vals = xap_terms($pfx, $old); + $doc->add_boolean_term($pfx.$_) for keys %$vals; + } + } $self->{xdb}->replace_document($smsg->{num}, $doc); } @@ -531,8 +541,6 @@ sub remove_eidx_info { $self->{xdb}->replace_document($docid, $doc); } -my @VMD_MAP = (kw => 'K', label => 'L'); - sub set_vmd { my ($self, $docid, $vmd) = @_; begin_txn_lazy($self); |