about summary refs log tree commit homepage
path: root/lib/PublicInbox/Search.pm
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-03-29 09:57:51 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-03-29 10:00:03 +0000
commit821ed7c40b7b50ceb1c942af5e14d168995d514e (patch)
treed061fb524e16f3e61617a5b09564892f557e06e6 /lib/PublicInbox/Search.pm
parent623136f21efe82bf88fcd7fc4c733502c59f63e8 (diff)
downloadpublic-inbox-821ed7c40b7b50ceb1c942af5e14d168995d514e.tar.gz
The only Xapian term which should be unique is the NNTP article
number; so we no longer need find_unique_doc_id.
Diffstat (limited to 'lib/PublicInbox/Search.pm')
-rw-r--r--lib/PublicInbox/Search.pm24
1 files changed, 8 insertions, 16 deletions
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index a4e2498e..584a508e 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -396,9 +396,16 @@ sub lookup_article {
                 retry_reopen($self, sub {
                         my $db = $self->{skel} || $self->{xdb};
                         my $head = $db->postlist_begin($term);
-                        return if $head == $db->postlist_end($term);
+                        my $tail = $db->postlist_end($term);
+                        return if $head->equal($tail);
                         my $doc_id = $head->get_docid;
                         return unless defined $doc_id;
+                        $head->inc;
+                        if ($head->nequal($tail)) {
+                                my $loc= $self->{mainrepo} .
+                                        ($self->{skel} ? 'skel' : 'xdb');
+                                warn "article #$num is not unique in $loc\n";
+                        }
                         # raises on error:
                         my $doc = $db->get_document($doc_id);
                         $smsg = PublicInbox::SearchMsg->wrap($doc);
@@ -432,21 +439,6 @@ sub each_smsg_by_mid {
         }
 }
 
-sub find_unique_doc_id {
-        my ($self, $termval) = @_;
-
-        my ($begin, $end) = $self->find_doc_ids($termval);
-
-        return undef if $begin->equal($end); # not found
-
-        my $rv = $begin->get_docid;
-
-        # sanity check
-        $begin->inc;
-        $begin->equal($end) or die "Term '$termval' is not unique\n";
-        $rv;
-}
-
 # returns begin and end PostingIterator
 sub find_doc_ids {
         my ($self, $termval) = @_;