about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiSearch.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-01-21 19:46:14 +0000
committerEric Wong <e@80x24.org>2021-01-22 16:18:01 -0400
commitbf77d62faa571cdaf279df421aae85d2b447ceeb (patch)
tree9a342476340dcc9763443ceb8eb8b6010e6a584e /lib/PublicInbox/LeiSearch.pm
parent7e947c849e3ceeb89c3d27952abdb10f9252c038 (diff)
downloadpublic-inbox-bf77d62faa571cdaf279df421aae85d2b447ceeb.tar.gz
This isn't tested for now, so maybe it works.
Diffstat (limited to 'lib/PublicInbox/LeiSearch.pm')
-rw-r--r--lib/PublicInbox/LeiSearch.pm16
1 files changed, 3 insertions, 13 deletions
diff --git a/lib/PublicInbox/LeiSearch.pm b/lib/PublicInbox/LeiSearch.pm
index b7e337de..440bacf5 100644
--- a/lib/PublicInbox/LeiSearch.pm
+++ b/lib/PublicInbox/LeiSearch.pm
@@ -5,7 +5,7 @@ package PublicInbox::LeiSearch;
 use strict;
 use v5.10.1;
 use parent qw(PublicInbox::ExtSearch);
-use PublicInbox::Search;
+use PublicInbox::Search qw(xap_terms);
 
 # get combined docid from over.num:
 # (not generic Xapian, only works with our sharding scheme)
@@ -19,19 +19,9 @@ sub msg_keywords {
         my ($self, $num) = @_; # num_or_mitem
         my $xdb = $self->xdb; # set {nshard};
         my $docid = ref($num) ? $num->get_docid : num2docid($self, $num);
-        my %kw;
-        eval {
-                my $end = $xdb->termlist_end($docid);
-                my $cur = $xdb->termlist_begin($docid);
-                for (; $cur != $end; $cur++) {
-                        $cur->skip_to('K');
-                        last if $cur == $end;
-                        my $kw = $cur->get_termname;
-                        $kw =~ s/\AK//s and $kw{$kw} = undef;
-                }
-        };
+        my $kw = xap_terms('K', $xdb, $docid);
         warn "E: #$docid ($num): $@\n" if $@;
-        wantarray ? sort(keys(%kw)) : \%kw;
+        wantarray ? sort(keys(%$kw)) : $kw;
 }
 
 1;