From 3f4c9ce3d2c0796c6c3f352b5b586ddd7a85ffb0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 31 Jul 2016 00:02:06 +0000 Subject: search: support reindexing existing search indices This should make tweaking the way we search more efficiet by allowing us to avoid doubling destroying the index every time we want to change something. We also give priority to incremental indexing via public-inbox-{watch,mda} and have manual invocations of public-inbox-index perform batch updates while releasing ssoma.lock. --- script/public-inbox-index | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'script/public-inbox-index') diff --git a/script/public-inbox-index b/script/public-inbox-index index 46584c1f..61f21d70 100755 --- a/script/public-inbox-index +++ b/script/public-inbox-index @@ -8,6 +8,7 @@ use strict; use warnings; +use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev); my $usage = "public-inbox-index GIT_DIR"; use PublicInbox::Config; eval { require PublicInbox::SearchIdx }; @@ -15,6 +16,11 @@ if ($@) { print STDERR "Search::Xapian required for $0\n"; exit 1; } + +my $reindex; +my %opts = ( '--reindex' => \$reindex ); +GetOptions(%opts) or die "bad command-line args\n$usage"; + my @dirs; sub resolve_git_dir { @@ -57,7 +63,6 @@ foreach my $dir (@dirs) { sub index_dir { my ($git_dir) = @_; -d $git_dir or die "$git_dir does not appear to be a git repository\n"; - my $s = PublicInbox::SearchIdx->new($git_dir, 1); - $s->index_sync; + $s->index_sync({ reindex => $reindex }); } -- cgit v1.2.3-24-ge0c7