324 |
my $self = {}; |
my $self = {}; |
325 |
bless($self, $class); |
bless($self, $class); |
326 |
|
|
327 |
|
$self->{max} = -1; |
328 |
|
$self->{options} = 0; |
329 |
|
|
330 |
$self ? return $self : return undef; |
$self ? return $self : return undef; |
331 |
} |
} |
332 |
|
|
405 |
$self->{options} ||= $options->{$option}; |
$self->{options} ||= $options->{$option}; |
406 |
} |
} |
407 |
|
|
408 |
|
=head2 phrase |
409 |
|
|
410 |
|
Return search phrase. |
411 |
|
|
412 |
|
print $cond->phrase; |
413 |
|
|
414 |
|
=cut |
415 |
|
|
416 |
|
sub phrase { |
417 |
|
my $self = shift; |
418 |
|
return $self->{phrase}; |
419 |
|
} |
420 |
|
|
421 |
|
=head2 order |
422 |
|
|
423 |
|
Return search result order. |
424 |
|
|
425 |
|
print $cond->order; |
426 |
|
|
427 |
|
=cut |
428 |
|
|
429 |
|
sub order { |
430 |
|
my $self = shift; |
431 |
|
return $self->{order}; |
432 |
|
} |
433 |
|
|
434 |
|
=head2 attrs |
435 |
|
|
436 |
|
Return search result attrs. |
437 |
|
|
438 |
|
my @cond_attrs = $cond->attrs; |
439 |
|
|
440 |
|
=cut |
441 |
|
|
442 |
|
sub attrs { |
443 |
|
my $self = shift; |
444 |
|
#croak "attrs return array, not scalar" if (! wantarray); |
445 |
|
return @{ $self->{attrs} }; |
446 |
|
} |
447 |
|
|
448 |
|
=head2 max |
449 |
|
|
450 |
|
Return maximum number of results. |
451 |
|
|
452 |
|
print $cond->max; |
453 |
|
|
454 |
|
C<-1> is returned for unitialized value, C<0> is unlimited. |
455 |
|
|
456 |
|
=cut |
457 |
|
|
458 |
|
sub max { |
459 |
|
my $self = shift; |
460 |
|
return $self->{max}; |
461 |
|
} |
462 |
|
|
463 |
|
=head2 options |
464 |
|
|
465 |
|
Return options for this condition. |
466 |
|
|
467 |
|
print $cond->options; |
468 |
|
|
469 |
|
Options are returned in numerical form. |
470 |
|
|
471 |
|
=cut |
472 |
|
|
473 |
|
sub options { |
474 |
|
my $self = shift; |
475 |
|
return $self->{options}; |
476 |
|
} |
477 |
|
|
478 |
|
|
479 |
|
package Search::Estraier::ResultDocument; |
480 |
|
|
481 |
|
use Carp qw/confess croak/; |
482 |
|
|
483 |
|
use Search::Estraier; |
484 |
|
our @ISA = qw/Search::Estraier/; |
485 |
|
|
486 |
|
=head1 Search::Estraier::ResultDocument |
487 |
|
|
488 |
|
=head2 new |
489 |
|
|
490 |
|
my $doc = new Search::HyperEstraier::ResultDocument( |
491 |
|
uri => 'http://localhost/document/uri/42', |
492 |
|
attrs => { |
493 |
|
foo => 1, |
494 |
|
bar => 2, |
495 |
|
}, |
496 |
|
snippet => 'this is a text of snippet' |
497 |
|
keywords => 'this\tare\tkeywords' |
498 |
|
); |
499 |
|
|
500 |
|
=cut |
501 |
|
|
502 |
|
sub new { |
503 |
|
my $class = shift; |
504 |
|
my $self = {@_}; |
505 |
|
bless($self, $class); |
506 |
|
|
507 |
|
foreach my $f (qw/uri attrs snippet keywords/) { |
508 |
|
croak "missing $f for ResultDocument" unless defined($self->{$f}); |
509 |
|
} |
510 |
|
|
511 |
|
$self ? return $self : return undef; |
512 |
|
} |
513 |
|
|
514 |
|
|
515 |
|
|
516 |
package Search::Estraier::Master; |
package Search::Estraier::Master; |
517 |
|
|
518 |
use Carp; |
use Carp; |