Available in public-inbox 1.6.0+.
+=item --update-extindex=EXTINDEX, -E
+
+Update the given external index (L<public-inbox-extindex-format(5)>.
+Either the configured section name (e.g. C<all>) or a directory name
+may be specified.
+
+Defaults to C<all> if C<[extindex "all"]> is configured,
+otherwise no external indices are updated.
+
+May be specified multiple times in rare cases where multiple
+external indices are configured.
+
+=item --no-update-extindex
+
+Do not update the C<all> external index by default. This negates
+all uses of C<-E> / C<--update-extindex=> on the command-line.
+
=back
=head1 FILES
=head1 SEE ALSO
-L<Search::Xapian>, L<DBD::SQLite>
+L<Search::Xapian>, L<DBD::SQLite>, L<public-inbox-extindex-format(5)>
--no-fsync speed up indexing, risk corruption on power outage
-L LEVEL `basic', `medium', or `full' (default: full)
- -E EIDX update EIDX (e.g. `all')
+ -E EXTINDEX update extindex (default: `all')
--all index all configured inboxes
--compact | -c run public-inbox-compact(1) after indexing
--sequential-shard index Xapian shards sequentially for slow storage
BYTES may use `k', `m', and `g' suffixes (e.g. `10m' for 10 megabytes)
See public-inbox-index(1) man page for full documentation.
EOF
-my $opt = { quiet => -1, compact => 0, max_size => undef, fsync => 1 };
+my $opt = {
+ quiet => -1, compact => 0, max_size => undef, fsync => 1,
+ 'update-extindex' => [], # ":s@" optional arg sets '' if no arg given
+};
GetOptions($opt, qw(verbose|v+ reindex rethread compact|c+ jobs|j=i prune
fsync|sync! xapian_only|xapian-only
indexlevel|index-level|L=s max_size|max-size=s
batch_size|batch-size=s
sequential_shard|seq-shard|sequential-shard
+ no-update-extindex update-extindex|E=s@
skip-docdata all help|h))
or die $help;
if ($opt->{help}) { print $help; exit 0 };
PublicInbox::Admin::require_or_die('-index');
unless (@ibxs) { print STDERR $help; exit 1 }
+my (@eidx_dir, %eidx_seen);
+my $update_extindex = $opt->{'update-extindex'};
+if (!scalar(@$update_extindex) && (my $ALL = $cfg->ALL)) {
+ # extindex and normal inboxes may have different owners
+ push(@$update_extindex, 'all') if -w $ALL->{topdir};
+}
+@$update_extindex = () if $opt->{'no-update-extindex'};
+if (scalar @$update_extindex) {
+ PublicInbox::Admin::require_or_die('-search');
+ require PublicInbox::ExtSearchIdx;
+}
+for my $ei_name (@$update_extindex) {
+ my $es = $cfg->lookup_ei($ei_name);
+ my $topdir;
+ if (!$es && -d $ei_name) { # allow dirname or config section name
+ $topdir = $ei_name;
+ } elsif ($es) {
+ $topdir = $es->{topdir};
+ } else {
+ die "extindex `$ei_name' not configured or found\n";
+ }
+ $eidx_seen{$topdir} //= push(@eidx_dir, $topdir);
+}
my $mods = {};
+my @eidx_unconfigured;
foreach my $ibx (@ibxs) {
# detect_indexlevel may also set $ibx->{-skip_docdata}
my $detected = PublicInbox::Admin::detect_indexlevel($ibx);
$ibx->{indexlevel} //= $opt->{indexlevel} // ($opt->{xapian_only} ?
'full' : $detected);
PublicInbox::Admin::scan_ibx_modules($mods, $ibx);
+ if (@eidx_dir && $ibx->{-unconfigured}) {
+ push @eidx_unconfigured, " $ibx->{inboxdir}\n";
+ }
}
+warn <<EOF if @eidx_unconfigured;
+The following inboxes are unconfigured and will not be updated in
+@$update_extindex:\n@eidx_unconfigured
+EOF
# "Search::Xapian" includes SWIG "Xapian", too:
$opt->{compact} = 0 if !$mods->{'Search::Xapian'};
local $copt->{jobs} = 0 if $ibx_opt->{sequential_shard};
PublicInbox::Xapcmd::run($ibx, 'compact', $copt);
}
+ next if $ibx->{-unconfigured};
+ last if $ibx_opt->{quit};
+ for my $dir (@eidx_dir) {
+ my $eidx = PublicInbox::ExtSearchIdx->new($dir);
+ $eidx->attach_inbox($ibx);
+ $eidx->eidx_sync($ibx_opt);
+ last if $ibx_opt->{quit};
+ }
}