]> Sergey Matveev's repositories - public-inbox.git/commitdiff
searchidx: add NNTP article number as a searchable term
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Sat, 3 Mar 2018 17:42:20 +0000 (17:42 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Sat, 3 Mar 2018 17:42:20 +0000 (17:42 +0000)
Since we support duplicate MIDs in v2, the NNTP article number
becomes the true unique identifier and we want a way to do fast
lookups on it.

While we're at it, stop putting XPATH in the term partitions
since we only need it in the skeleton DB.

lib/PublicInbox/SearchIdx.pm
lib/PublicInbox/SearchIdxSkeleton.pm

index f63e07200b08d9d970d5e43c10cc8f70da0508af..3ef444d67ea0af8f2fba679ea3a19360d556e13f 100644 (file)
@@ -322,7 +322,6 @@ sub add_message {
                if ($subj ne '') {
                        $xpath = $self->subject_path($subj);
                        $xpath = id_compress($xpath);
-                       $doc->add_boolean_term('XPATH' . $xpath);
                }
 
                my $lines = $mime->body_raw =~ tr!\n!\n!;
@@ -398,7 +397,8 @@ sub add_message {
                        $skel->index_skeleton(\@values);
                        $doc_id = $self->{xdb}->add_document($doc);
                } else {
-                       $doc_id = link_and_save($self, $doc, $mids, $refs);
+                       $doc_id = link_and_save($self, $doc, $mids, $refs,
+                                               $num, $xpath);
                }
        };
 
@@ -504,10 +504,12 @@ sub link_doc {
 }
 
 sub link_and_save {
-       my ($self, $doc, $mids, $refs) = @_;
+       my ($self, $doc, $mids, $refs, $num, $xpath) = @_;
        my $db = $self->{xdb};
        my $old_tid;
        my $doc_id;
+       $doc->add_boolean_term('XNUM' . $num) if defined $num;
+       $doc->add_boolean_term('XPATH' . $xpath) if defined $xpath;
        my $vivified = 0;
        foreach my $mid (@$mids) {
                $self->each_smsg_by_mid($mid, sub {
index 3fe6a4ad105c6a705ad6f36e1a877c0b1a6346f4..4066b5915470872b2fc766e45650534b62560469 100644 (file)
@@ -98,7 +98,6 @@ sub index_skeleton_real ($$) {
        my $ts = $values->[PublicInbox::Search::TS];
        my $smsg = PublicInbox::SearchMsg->new(undef);
        my $doc = $smsg->{doc};
-       $doc->add_boolean_term('XPATH' . $xpath) if defined $xpath;
        foreach my $mid (@$mids) {
                $doc->add_term('Q' . $mid);
        }
@@ -106,8 +105,9 @@ sub index_skeleton_real ($$) {
        $doc->set_data($doc_data);
        $smsg->{ts} = $ts;
        $smsg->load_from_data($doc_data);
+       my $num = $values->[PublicInbox::Search::NUM];
        my @refs = ($smsg->references =~ /<([^>]+)>/g);
-       $self->link_and_save($doc, $mids, \@refs);
+       $self->link_and_save($doc, $mids, \@refs, $num, $xpath);
 }
 
 1;