17 |
my $dsn = $Conf{SearchDSN}; |
my $dsn = $Conf{SearchDSN}; |
18 |
my $db_user = $Conf{SearchUser} || ''; |
my $db_user = $Conf{SearchUser} || ''; |
19 |
|
|
20 |
my $hest_index_path = $Conf{HyperEstraierIndex}; |
my $hest_node_url = $Conf{HyperEstraierIndex}; |
21 |
|
|
22 |
my $dbh; |
my $dbh; |
23 |
|
|
251 |
|
|
252 |
return unless $use_hest; |
return unless $use_hest; |
253 |
|
|
254 |
use HyperEstraier; |
use Search::Estraier; |
255 |
my ($index_path, $index_node_url); |
die "direct access to Hyper Estraier datatase is no longer supported. Please use estmaster\n" |
256 |
|
unless ($use_hest =~ m#^http://#); |
257 |
|
|
258 |
if ($use_hest =~ m#^http://#) { |
return $use_hest; |
|
$index_node_url = $use_hest; |
|
|
} else { |
|
|
$index_path = $TopDir . '/' . $use_hest; |
|
|
$index_path =~ s#//#/#g; |
|
|
} |
|
|
return ($index_path, $index_node_url); |
|
259 |
} |
} |
260 |
|
|
261 |
sub getFilesHyperEstraier($) { |
sub getFilesHyperEstraier($) { |
264 |
my $offset = $param->{'offset'} || 0; |
my $offset = $param->{'offset'} || 0; |
265 |
$offset *= $on_page; |
$offset *= $on_page; |
266 |
|
|
267 |
die "no index_path?" unless ($hest_index_path); |
die "no Hyper Estraier node URL?" unless ($hest_node_url); |
|
|
|
|
use HyperEstraier; |
|
|
|
|
|
my ($index_path, $index_node_url) = getHyperEstraier_url($hest_index_path); |
|
268 |
|
|
269 |
# open the database |
# open the database |
270 |
my $db; |
my $db; |
271 |
if ($index_path) { |
if ($hest_node_url) { |
272 |
$db = HyperEstraier::Database->new(); |
$db ||= Search::Estraier::Node->new($hest_node_url); |
|
$db->open($index_path, $HyperEstraier::ESTDBREADER); |
|
|
} elsif ($index_node_url) { |
|
|
$db ||= HyperEstraier::Node->new($index_node_url); |
|
273 |
$db->set_auth('admin', 'admin'); |
$db->set_auth('admin', 'admin'); |
274 |
} else { |
} else { |
275 |
die "BUG: unimplemented"; |
die "BUG: unimplemented"; |
276 |
} |
} |
277 |
|
|
278 |
# create a search condition object |
# create a search condition object |
279 |
my $cond = HyperEstraier::Condition->new(); |
my $cond = Search::Estraier::Condition->new(); |
280 |
|
|
281 |
my $q = $param->{'search_filename'}; |
my $q = $param->{'search_filename'}; |
282 |
my $shareid = $param->{'search_share'}; |
my $shareid = $param->{'search_share'}; |
301 |
$cond->add_attr("shareid NUMEQ $shareid") if ($shareid); |
$cond->add_attr("shareid NUMEQ $shareid") if ($shareid); |
302 |
|
|
303 |
# $cond->set_max( $offset + $on_page ); |
# $cond->set_max( $offset + $on_page ); |
304 |
$cond->set_options( $HyperEstraier::Condition::SURE ); |
$cond->set_options( SURE => 1 ); |
305 |
$cond->set_order( getSort('search', 'est', $param->{'sort'} ) ); |
$cond->set_order( getSort('search', 'est', $param->{'sort'} ) ); |
306 |
|
|
307 |
# get the result of search |
# get the result of search |
308 |
my @res; |
my @res; |
309 |
my ($result, $hits); |
my ($result, $hits); |
310 |
|
|
311 |
if ($index_path) { |
if ($hest_node_url) { |
312 |
$result = $db->search($cond, 0); |
$result = $db->search($cond, 0); |
313 |
$hits = $result->size; |
if ($result) { |
314 |
} elsif ($index_node_url) { |
$hits = $result->doc_num; |
315 |
$result = $db->search($cond, 0); |
} else { |
316 |
$hits = $result->doc_num; |
$hits = 0; |
317 |
|
} |
318 |
} else { |
} else { |
319 |
die "BUG: unimplemented"; |
die "BUG: unimplemented"; |
320 |
} |
} |
324 |
last if ($i >= $hits); |
last if ($i >= $hits); |
325 |
|
|
326 |
my $doc; |
my $doc; |
327 |
if ($index_path) { |
if ($hest_node_url) { |
|
my $id = $result->get($i); |
|
|
$doc = $db->get_doc($id, 0); |
|
|
} elsif ($index_node_url) { |
|
328 |
$doc = $result->get_doc($i); |
$doc = $result->get_doc($i); |
329 |
} else { |
} else { |
330 |
die "BUG: unimplemented"; |
die "BUG: unimplemented"; |