about summary refs log tree commit homepage
path: root/lib/PublicInbox/Search.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-03-21 23:07:17 +0000
committerEric Wong <e@80x24.org>2023-03-25 09:37:41 +0000
commit852c6ff55c8ac33882defd224fee169cb90caa26 (patch)
treeb34bd6f5a2775f592933f93c1e37f29d964d100d /lib/PublicInbox/Search.pm
parent9225145d3e98d83889065f6d4dc4913226e5f121 (diff)
downloadpublic-inbox-852c6ff55c8ac33882defd224fee169cb90caa26.tar.gz
This will be used for code_search, too.
Diffstat (limited to 'lib/PublicInbox/Search.pm')
-rw-r--r--lib/PublicInbox/Search.pm14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index e858729a..7aba2445 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -553,4 +553,18 @@ sub num2docid ($$) {
         ($num - 1) * $nshard + $num % $nshard + 1;
 }
 
+sub all_terms {
+        my ($self, $pfx) = @_;
+        my $cur = xdb($self)->allterms_begin($pfx);
+        my $end = $self->{xdb}->allterms_end($pfx);
+        my %ret;
+        for (; $cur != $end; $cur++) {
+                my $tn = $cur->get_termname;
+                index($tn, $pfx) == 0 and
+                        $ret{substr($tn, length($pfx))} = undef;
+        }
+        wantarray ? (sort keys %ret) : \%ret;
+}
+
+
 1;