lib/PublicInbox/Search.pm | 3 ++- lib/PublicInbox/SearchIdx.pm | 5 +++-- diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 8c0bab185d489008356e8efeafa641893549eac7..bf50365a04603d86d9722a923e4a36f0b8287c77 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -36,7 +36,8 @@ # 7 - remove references and inreplyto terms # 8 - remove redundant/unneeded document data # 9 - disable Message-ID compression (SHA-1) # 10 - optimize doc for NNTP overviews - SCHEMA_VERSION => 10, + # 11 - merge threads when vivifying ghosts + SCHEMA_VERSION => 11, # n.b. FLAG_PURE_NOT is expensive not suitable for a public website # as it could become a denial-of-service vector diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 31346876bcfefdd1f123d2537e1a06313db1e2cc..58eccc1a2d67241ed273e940fee0d1fb2b27c51d 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -150,7 +150,7 @@ }); if ($was_ghost) { $doc_id = $smsg->doc_id; - $self->link_message($smsg); + $self->link_message($smsg, $smsg->thread_id); $doc->set_data($smsg->to_doc_data); $db->replace_document($doc_id, $doc); } else { @@ -211,7 +211,7 @@ $last_thread_id; } sub link_message { - my ($self, $smsg) = @_; + my ($self, $smsg, $old_tid) = @_; my $doc = $smsg->{doc}; my $mid = $smsg->mid; my $mime = $smsg->mime; @@ -247,6 +247,7 @@ # first ref *should* be the thread root, # but we can never trust clients to do the right thing my $ref = shift @refs; $tid = $self->_resolve_mid_to_tid($ref); + $self->merge_threads($tid, $old_tid) if defined $old_tid; # the rest of the refs should point to this tid: foreach $ref (@refs) {