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/Search.pm | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'lib/PublicInbox/Search.pm') diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index bbc5e32f..bca2036c 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -196,6 +196,7 @@ sub xdb_shards_flat ($) { my ($self) = @_; my $xpfx = $self->{xpfx}; my (@xdb, $slow_phrase); + load_xapian(); if ($xpfx =~ m/xapian${\SCHEMA_VERSION}\z/) { @xdb = ($X{Database}->new($xpfx)); $self->{qp_flags} |= FLAG_PHRASE() if !-f "$xpfx/iamchert"; @@ -214,16 +215,6 @@ sub xdb_shards_flat ($) { @xdb; } -sub _xdb { - my ($self) = @_; - $self->{qp_flags} //= $QP_FLAGS; - my @xdb = xdb_shards_flat($self) or return; - $self->{nshard} = scalar(@xdb); - my $xdb = shift @xdb; - $xdb->add_database($_) for @xdb; - $xdb; -} - # v2 Xapian docids don't conflict, so they're identical to # NNTP article numbers and IMAP UIDs. # https://trac.xapian.org/wiki/FAQ/MultiDatabaseDocumentID @@ -242,8 +233,12 @@ sub mset_to_artnums { sub xdb ($) { my ($self) = @_; $self->{xdb} //= do { - load_xapian(); - $self->_xdb; + $self->{qp_flags} //= $QP_FLAGS; + my @xdb = $self->xdb_shards_flat or return; + $self->{nshard} = scalar(@xdb); + my $xdb = shift @xdb; + $xdb->add_database($_) for @xdb; + $xdb; }; } -- cgit v1.2.3-24-ge0c7