--- trunk/lib/BackupPC/SearchLib.pm 2006/01/27 17:45:49 302 +++ trunk/lib/BackupPC/SearchLib.pm 2006/01/28 16:45:46 303 @@ -17,7 +17,7 @@ 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 @@ 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 @@ 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 @@ $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 @@ 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";