diff options
author | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-03-21 09:04:50 +0000 |
---|---|---|
committer | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-03-22 00:19:17 +0000 |
commit | 3a4394468b4a9affc38f8e0f56011adb72269ec2 (patch) | |
tree | 850d0f5c36d04b68c736a0f4a4f918c5dd3d1d41 /lib/PublicInbox/SearchIdx.pm | |
parent | b41c5982647a8ecccbadf159381840d74d36248a (diff) | |
download | public-inbox-3a4394468b4a9affc38f8e0f56011adb72269ec2.tar.gz |
This still requires a msgmap.sqlite3 file to exist, but it allows us to tweak Xapian indexing rules and reindex the Xapian database online while -watch is running.
Diffstat (limited to 'lib/PublicInbox/SearchIdx.pm')
-rw-r--r-- | lib/PublicInbox/SearchIdx.pm | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index ef723a4b..7ac16ec2 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -352,7 +352,7 @@ sub add_message { # populates smsg->references for smsg->to_doc_data my $refs = parse_references($smsg); - $mid0 = $mids->[0] unless defined $mid0; + $mid0 = $mids->[0] unless defined $mid0; # v1 compatibility my $data = $smsg->to_doc_data($oid, $mid0); foreach my $mid (@$mids) { $tg->index_text($mid, 1, 'XM'); @@ -369,10 +369,12 @@ sub add_message { } } + $self->delete_article($num) if defined $num; # for reindexing if ($skel) { push @values, $mids, $xpath, $data; $skel->index_skeleton(\@values); $doc->add_boolean_term('Q' . $_) foreach @$mids; + $doc->add_boolean_term('XNUM' . $num) if defined $num; $doc_id = $self->{xdb}->add_document($doc); } else { $doc_id = link_and_save($self, $doc, $mids, $refs, @@ -421,6 +423,16 @@ sub remove_message { } } +sub delete_article { + my ($self, $num) = @_; + my $ndel = 0; + batch_do($self, 'XNUM' . $num, sub { + my ($ids) = @_; + $ndel += scalar @$ids; + $self->{xdb}->delete_document($_) for @$ids; + }); +} + # MID is a hint in V2 sub remove_by_oid { my ($self, $oid, $mid) = @_; |