+ custom logo
+ creation of tar increments
+ user HyperEstraier node API for creation
++ use Search::Estraier pure perl module
- use pgest from PostgreSQL for queries to HyperEstraier (through node API)
- update to upstream BackupPC 2.1.2
- check for invalid dates in input form
Site-specific:
-- Apache user authentification over AD
++ Apache user authentification over AD
- per host (xr1) specific black-out period
- remove BackupPC in title bar
my $dsn = $Conf{SearchDSN} || die "Need SearchDSN in config.pl\n";
my $user = $Conf{SearchUser} || '';
-my $use_hest = $Conf{HyperEstraierIndex};
-my ($index_path, $index_node_url) = BackupPC::SearchLib::getHyperEstraier_url($use_hest);
+my $index_node_url = $Conf{HyperEstraierIndex};
my $dbh = DBI->connect($dsn, $user, "", { RaiseError => 1, AutoCommit => 0 });
$debug = $opt{v};
} elsif ($opt{f}) {
print "WARNING: disabling full-text index update. You need to re-run $0 -j !\n";
- ($use_hest, $index_path, $index_node_url) = (undef, undef, undef);
+ $index_node_url = undef;
}
#---- subs ----
my $skip_check = $opt{j} && print STDERR "Skipping check for existing files -- this should be used only with initital import\n";
- unless (defined($use_hest)) {
+ unless (defined($index_node_url)) {
print STDERR "HyperEstraier support not enabled in configuration\n";
- $use_hest = 0;
+ $index_node_url = 0;
return;
}
- return unless($use_hest);
-
- print curr_time," updating HyperEstraier:";
+ print curr_time," updating Hyper Estraier:";
my $t = time();
my $offset = 0;
my $added = 0;
- print " opening index $use_hest";
- if ($index_path) {
- $hest_db = HyperEstraier::Database->new();
- $hest_db->open($TopDir . $index_path, $HyperEstraier::Database::DBWRITER | $HyperEstraier::Database::DBCREAT);
- print " directly";
- } elsif ($index_node_url) {
- $hest_node ||= HyperEstraier::Node->new($index_node_url);
+ print " opening index $index_node_url";
+ if ($index_node_url) {
+ $hest_node ||= Search::Estraier::Node->new($index_node_url);
$hest_node->set_auth('admin', 'admin');
print " via node URL";
} else {
- die "don't know how to use HyperEstraier Index $use_hest";
+ die "don't know how to use Hyper Estraier Index $index_node_url";
}
- print " increment is " . EST_CHUNK . " files:";
my $results = 0;
if ($results == 0) {
print " - no new files\n";
last;
+ } else {
+ print " - $results files: ";
}
sub fmt_date {
}
# create a document object
- my $doc = HyperEstraier::Document->new;
+ my $doc = Search::Estraier::Document->new;
# add attributes to the document object
$doc->add_attr('@uri', $uri);
print STDERR $doc->dump_draft,"\n" if ($debug > 1);
# register the document object to the database
- if ($hest_db) {
- $hest_db->put_doc($doc, $HyperEstraier::Database::PDCLEAN);
- } elsif ($hest_node) {
+ if ($hest_node) {
$hest_node->put_doc($doc);
} else {
die "not supported";
}
print " $added";
- $hest_db->sync() if ($index_path);
$offset += EST_CHUNK;
} while ($results == EST_CHUNK);
- if ($index_path) {
- print ", close";
- $hest_db->close();
- }
-
my $dur = (time() - $t) || 1;
printf(" [%.2f/s dur: %s]\n",
( $added / $dur ),
## update index ##
-if (($opt{i} || $opt{j} || ($index_path && ! -e $TopDir . $index_path)) && !$opt{c}) {
+if ( ( $opt{i} || $opt{j} ) && !$opt{c} ) {
# update all
- print "force update of HyperEstraier index ";
- print "importing existing data" unless (-e $TopDir . $index_path);
+ print "force update of Hyper Estraier index ";
print "by -i flag" if ($opt{i});
print "by -j flag" if ($opt{j});
print "\n";
$Conf{SearchDSN} = 'dbi:Pg:dbname=backuppc';
$Conf{SearchUser} = 'dpavlin';
#
-# if you want to use experimental HyperEstraier support (which require
-# installation of HyperEstraier and swig binding for perl) select
+# if you want to use experimental Hyper Estraier support (which require
+# installation of Search::Estraier perl module from CPAN) select
# path to index (relative to $TopDir) or node URI
#$Conf{HyperEstraierIndex} = '/casket/';
$Conf{HyperEstraierIndex} = 'http://localhost:1978/node/backuppc';
=head2 Requirements
-This extension is based on PostgreSQL RDBMS and HyperEstraier full-text
+This extension is based on PostgreSQL RDBMS and Hyper Estraier full-text
search engine (and it's perl bindings).
If you are using Debian, you are in luck. All required packages are
# apt-get install postgresql
# apt-get install hyperestraier libestraier-dev libqdbm-dev
-Now you can skip to installation of L<HyperEstraier perl bindings> below.
+Now you can skip to installation of L<Hyper Estraier perl bindings> below.
If you don't have pre-packaged binaries for your installation, you will
need to install additional packages by hand.
=head3 QDBM
-First, you need qdbm on which HyperEstraier depends. Installation is simple.
+First, you need qdbm on which Hyper Estraier depends. Installation is simple.
$ tar xvfz qdbm-1.8.31.tar.gz
$ cd qdbm-1.8.31
$ make
$ sudo make install
-=head3 HyperEstraier
+=head3 Hyper Estraier
Also quite simple.
$ make
$ sudo make install
-Then you will have to install perl bindings for HyperEstraier.
+Then you will have to install perl bindings for Hyper Estraier.
-=head3 HyperEstraier perl bindings
+=head3 Hyper Estraier perl bindings
-This might take a bit more work. You will need to have C<swig> and C<g++> installed
-before you can install perl bindings.
+Just use C<cpan> shell to install C<Search::Estraier> module
- $ tar xvfz hyper_estraier_wrappers-0.0.10.tar.gz
- $ cd swig_hest/perl/
- $ swig -c++ -perl5 -o HyperEstraier_wrap.cpp ../HyperEstraier.i
- $ cp ../HyperEstraierWrapper.cpp ./
- $ perl Makefile.PL
+ $ sudo cpan Search::Estraier
-You might need to remove C<estconfig --mtlibs> from C<Makefile.PL> if it
-fails to run with following message:
-
- Unrecognized argument in LIBS ignored: 'configuration'
- Unrecognized argument in LIBS ignored: 'helper'
- Unrecognized argument in LIBS ignored: 'for'
- Unrecognized argument in LIBS ignored: 'Hyper'
- Unrecognized argument in LIBS ignored: 'Estraier'
- Writing Makefile for HyperEstraier
-
-Working C<Makefile.PL> for my particular installation is:
-
- # File : Makefile.PL
- use ExtUtils::MakeMaker;
- WriteMakefile(
- NAME => 'HyperEstraier',
- INC => sprintf('%s', `pkg-config --cflags hyperestraier`),
- LIBS => [sprintf('-lstdc++ %s %s' , `pkg-config --libs hyperestraier`)],
- OBJECT => 'HyperEstraierWrapper.o HyperEstraier_wrap.o'
- );
-
-After succesfull C<perl Makefile.pl>, you can compile and install it.
-
- $ make
- $ sudo make install
+There was awaful long procedure about installing perl C bindings, but it's all gone now.
=head3 CPAN modules
=item File::Which
=item File::Path
=item File::Slurp
+=item Search::Estraier
=item Spreadsheet::WriteExcel
Easiest way to install them is using C<cpan> shell.
- $ sudo cpan File::Pid Spreadsheet::WriteExcel
+ $ sudo cpan File::Pid Spreadsheet::WriteExcel ...
=head1 Creation of initial database
my $dsn = $Conf{SearchDSN};
my $db_user = $Conf{SearchUser} || '';
-my $hest_index_path = $Conf{HyperEstraierIndex};
+my $hest_node_url = $Conf{HyperEstraierIndex};
my $dbh;
return unless $use_hest;
- use HyperEstraier;
- my ($index_path, $index_node_url);
+ use Search::Estraier;
+ die "direct access to Hyper Estraier datatase is no longer supported. Please use estmaster\n"
+ unless ($use_hest =~ m#^http://#);
- if ($use_hest =~ m#^http://#) {
- $index_node_url = $use_hest;
- } else {
- $index_path = $TopDir . '/' . $use_hest;
- $index_path =~ s#//#/#g;
- }
- return ($index_path, $index_node_url);
+ return $use_hest;
}
sub getFilesHyperEstraier($) {
my $offset = $param->{'offset'} || 0;
$offset *= $on_page;
- die "no index_path?" unless ($hest_index_path);
-
- use HyperEstraier;
-
- my ($index_path, $index_node_url) = getHyperEstraier_url($hest_index_path);
+ die "no Hyper Estraier node URL?" unless ($hest_node_url);
# open the database
my $db;
- if ($index_path) {
- $db = HyperEstraier::Database->new();
- $db->open($index_path, $HyperEstraier::ESTDBREADER);
- } elsif ($index_node_url) {
- $db ||= HyperEstraier::Node->new($index_node_url);
+ if ($hest_node_url) {
+ $db ||= Search::Estraier::Node->new($hest_node_url);
$db->set_auth('admin', 'admin');
} else {
die "BUG: unimplemented";
}
# create a search condition object
- my $cond = HyperEstraier::Condition->new();
+ my $cond = Search::Estraier::Condition->new();
my $q = $param->{'search_filename'};
my $shareid = $param->{'search_share'};
$cond->add_attr("shareid NUMEQ $shareid") if ($shareid);
# $cond->set_max( $offset + $on_page );
- $cond->set_options( $HyperEstraier::Condition::SURE );
+ $cond->set_options( SURE => 1 );
$cond->set_order( getSort('search', 'est', $param->{'sort'} ) );
# get the result of search
my @res;
my ($result, $hits);
- if ($index_path) {
+ if ($hest_node_url) {
$result = $db->search($cond, 0);
- $hits = $result->size;
- } elsif ($index_node_url) {
- $result = $db->search($cond, 0);
- $hits = $result->doc_num;
+ if ($result) {
+ $hits = $result->doc_num;
+ } else {
+ $hits = 0;
+ }
} else {
die "BUG: unimplemented";
}
last if ($i >= $hits);
my $doc;
- if ($index_path) {
- my $id = $result->get($i);
- $doc = $db->get_doc($id, 0);
- } elsif ($index_node_url) {
+ if ($hest_node_url) {
$doc = $result->get_doc($i);
} else {
die "BUG: unimplemented";