From 08de05443804120a2663aa3611c47c84a18e0c35 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 27 Dec 2020 20:02:51 +0000 Subject: lei_xsearch: cross-(inbox|extindex) search While a single extindex combines multiple inboxes into a single search index, extindex still requires up-front indexing on items which can be searched. XSearch has no on-disk footprint itself and uses Xapian DBs of existing publicinbox and extindex ("extinbox") exclusively. XSearch still suffers from the multi-shard Xapian scalability problems which led to the creation of extindex, but I expect the number of shards to remain relatively low. I envision users hosting public-inbox instances on their workstations will only have two extindex combined by this, one read-only extindex for serving public archives, and one read-write extindex managed by LeiStore for private mail. --- lib/PublicInbox/LeiSearch.pm | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lib/PublicInbox/LeiSearch.pm') diff --git a/lib/PublicInbox/LeiSearch.pm b/lib/PublicInbox/LeiSearch.pm index 66c16e04..0b962b11 100644 --- a/lib/PublicInbox/LeiSearch.pm +++ b/lib/PublicInbox/LeiSearch.pm @@ -7,20 +7,18 @@ use v5.10.1; use parent qw(PublicInbox::ExtSearch); use PublicInbox::Search; -sub combined_docid ($$) { +# get combined docid from over.num: +# (not generic Xapian, only works with our sharding scheme) +sub num2docid ($$) { my ($self, $num) = @_; - ($num - 1) * $self->{nshard} + 1; + my $nshard = $self->{nshard}; + ($num - 1) * $nshard + $num % $nshard + 1; } sub msg_keywords { my ($self, $num) = @_; # num_or_mitem my $xdb = $self->xdb; # set {nshard}; - my $docid = ref($num) ? $num->get_docid : do { - # get combined docid from over.num: - # (not generic Xapian, only works with our sharding scheme) - my $nshard = $self->{nshard}; - ($num - 1) * $nshard + $num % $nshard + 1; - }; + my $docid = ref($num) ? $num->get_docid : num2docid($self, $num); my %kw; eval { my $end = $xdb->termlist_end($docid); -- cgit v1.2.3-24-ge0c7