switch to Search::Estraier. Needs more testing for sure!
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Sat, 28 Jan 2006 16:45:46 +0000 (16:45 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Sat, 28 Jan 2006 16:45:46 +0000 (16:45 +0000)
git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@303 8392b6e1-25fa-0310-8288-cc32f8e212ea

BUGS
bin/BackupPC_updatedb
conf/config.pl
doc/Search.pod
lib/BackupPC/SearchLib.pm

diff --git a/BUGS b/BUGS
index 20fa307..314af72 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -6,6 +6,7 @@
 + 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
@@ -23,7 +24,7 @@
 
 Site-specific:
 
-- Apache user authentification over AD
++ Apache user authentification over AD
 
 - per host (xr1) specific black-out period
 - remove BackupPC in title bar
index 1b254b2..d62110e 100755 (executable)
@@ -52,8 +52,7 @@ my $beenThere = {};
 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 });
 
@@ -87,7 +86,7 @@ if ($opt{v}) {
        $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 ----
@@ -127,34 +126,27 @@ sub hest_update {
 
        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;
 
@@ -202,6 +194,8 @@ sub hest_update {
                if ($results == 0) {
                        print " - no new files\n";
                        last;
+               } else {
+                       print " - $results files: ";
                }
 
                sub fmt_date {
@@ -222,7 +216,7 @@ sub hest_update {
                        }
 
                        # 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);
@@ -242,9 +236,7 @@ sub hest_update {
                        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";
@@ -253,17 +245,11 @@ sub hest_update {
                }
 
                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 ),
@@ -275,10 +261,9 @@ sub hest_update {
 
 
 ## 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";
index f9f334b..b7f9990 100644 (file)
@@ -1749,8 +1749,8 @@ $Conf{CgiCSSFile} = 'BackupPC_stnd.css';
 $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';
index 5c38f4d..719fa8d 100644 (file)
@@ -23,7 +23,7 @@ multiple copies and so on.
 
 =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
@@ -32,7 +32,7 @@ allready part of C<unstable> distribution and can be installed with:
   # 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.
@@ -44,7 +44,7 @@ instructions on PostgreSQL site.
 
 =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
@@ -52,7 +52,7 @@ First, you need qdbm on which HyperEstraier depends. Installation is simple.
   $ make
   $ sudo make install
 
-=head3 HyperEstraier
+=head3 Hyper Estraier
 
 Also quite simple.
 
@@ -62,44 +62,15 @@ 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
 
@@ -111,6 +82,7 @@ You will also need a few additional cpan modules
 =item File::Which
 =item File::Path
 =item File::Slurp
+=item Search::Estraier
 
 =item Spreadsheet::WriteExcel
 
@@ -126,7 +98,7 @@ C<BackupPC_xls_report> to generate Excel reports from your backup data.
 
 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
 
index e3f44e8..d8c0555 100644 (file)
@@ -17,7 +17,7 @@ my $pager_pages = 10;
 my $dsn = $Conf{SearchDSN};
 my $db_user = $Conf{SearchUser} || '';
 
-my $hest_index_path = $Conf{HyperEstraierIndex};
+my $hest_node_url = $Conf{HyperEstraierIndex};
 
 my $dbh;
 
@@ -251,16 +251,11 @@ sub getHyperEstraier_url($) {
 
        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($) {
@@ -269,26 +264,19 @@ 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'};
@@ -313,19 +301,20 @@ sub getFilesHyperEstraier($) {
        $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";
        }
@@ -335,10 +324,7 @@ sub getFilesHyperEstraier($) {
                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";