]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Search.pm
miscsearch: a new Xapian sub-DB for extindex
[public-inbox.git] / lib / PublicInbox / Search.pm
index 5a57657ff4da5b1332afe8db5ed39b35c06f7d4e..05d5a13320d230c2b60ca6f3990b856cd52d1437 100644 (file)
@@ -6,7 +6,7 @@
 package PublicInbox::Search;
 use strict;
 use parent qw(Exporter);
-our @EXPORT_OK = qw(mdocid);
+our @EXPORT_OK = qw(mdocid retry_reopen);
 use List::Util qw(max);
 
 # values for searching, changing the numeric value breaks
@@ -54,11 +54,11 @@ use constant {
 
 use PublicInbox::Smsg;
 use PublicInbox::Over;
-my $QP_FLAGS;
+our $QP_FLAGS;
 our %X = map { $_ => 0 } qw(BoolWeight Database Enquire QueryParser Stem);
 our $Xap; # 'Search::Xapian' or 'Xapian'
-my $NVRP; # '$Xap::'.('NumberValueRangeProcessor' or 'NumberRangeProcessor')
-my $ENQ_ASCENDING;
+our $NVRP; # '$Xap::'.('NumberValueRangeProcessor' or 'NumberRangeProcessor')
+our $ENQ_ASCENDING;
 
 sub load_xapian () {
        return 1 if defined $Xap;
@@ -190,9 +190,9 @@ sub xdir ($;$) {
        }
 }
 
-sub _xdb_sharded {
-       my ($self, $xpfx) = @_;
-       opendir(my $dh, $xpfx) or return; # not initialized yet
+sub xdb_sharded {
+       my ($self) = @_;
+       opendir(my $dh, $self->{xpfx}) or return; # not initialized yet
 
        # We need numeric sorting so shard[0] is first for reading
        # Xapian metadata, if needed
@@ -200,7 +200,7 @@ sub _xdb_sharded {
        return if !defined($last);
        my (@xdb, $slow_phrase);
        for (0..$last) {
-               my $shard_dir = "$xpfx/$_";
+               my $shard_dir = "$self->{xpfx}/$_";
                if (-d $shard_dir && -r _) {
                        push @xdb, $X{Database}->new($shard_dir);
                        $slow_phrase ||= -f "$shard_dir/iamchert";
@@ -221,7 +221,7 @@ sub _xdb {
        my $dir = xdir($self, 1);
        $self->{qp_flags} //= $QP_FLAGS;
        if ($self->{ibx_ver} >= 2) {
-               _xdb_sharded($self, $dir);
+               xdb_sharded($self);
        } else {
                $self->{qp_flags} |= FLAG_PHRASE() if !-f "$dir/iamchert";
                $X{Database}->new($dir);