/usr/lib/perl5/KinoSearch1/Search/Searchable.pm is in libkinosearch1-perl 1.00-1build3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | package KinoSearch1::Search::Searchable;
use strict;
use warnings;
use KinoSearch1::Util::ToolSet;
use base qw( KinoSearch1::Util::Class );
BEGIN {
__PACKAGE__->init_instance_vars(
# members
similarity => undef,
field_sims => undef, # {}
);
}
use KinoSearch1::Search::Similarity;
=begin comment
my $hits = $searchable->search($query_string);
my $hits = $searchable->search(
query => $query,
filter => $filter,
sort_spec => $sort_spec,
);
=end comment
=cut
sub search { shift->abstract_death }
=begin comment
my $explanation = $searchable->explain( $weight, $doc_num );
Provide an Explanation for how the document represented by $doc_num scored
agains $weight. Useful for probing the guts of Similarity.
=end comment
=cut
sub explain { shift->todo_death }
=begin comment
my $doc_num = $searchable->max_doc;
Return one larger than the largest doc_num.
=end comment
=cut
sub max_doc { shift->abstract_death }
=begin comment
my $doc = $searchable->fetch_doc($doc_num);
Generate a Doc object, retrieving the stored fields from the invindex.
=end comment
=cut
sub fetch_doc { shift->abstract_death }
=begin comment
my $doc_freq = $searchable->doc_freq($term);
Return the number of documents which contain this Term. Used for calculating
Weights.
=end comment
=cut
sub doc_freq { shift->abstract_death }
=begin comment
$searchable->set_similarity($sim);
$searchable->set_similarity( $field_name, $alternate_sim );
my $sim = $searchable->get_similarity;
my $alt_sim = $searchable->get_similarity($field_name);
Set or get Similarity. If a field name is included, set/retrieve the
Similarity instance for that field only.
=end comment
=cut
sub set_similarity {
if ( @_ == 3 ) {
my ( $self, $field_name, $sim ) = @_;
$self->{field_sims}{$field_name} = $sim;
}
else {
$_[0]->{similarity} = $_[1];
}
}
sub get_similarity {
my ( $self, $field_name ) = @_;
if ( defined $field_name and exists $self->{field_sims}{$field_name} ) {
return $self->{field_sims}{$field_name};
}
else {
return $self->{similarity};
}
}
# not sure these are needed (call $query->create_weight($searcher) instead)
sub create_weight { shift->unimplemented_death }
sub rewrite_query { shift->unimplemented_death }
sub doc_freqs {
my ( $self, $terms ) = @_;
my @doc_freqs = map { $self->doc_freq($_) } @$terms;
return \@doc_freqs;
}
sub close { }
1;
__END__
=begin devdocs
=head1 NAME
KinoSearch1::Search::Searchable - base class for searching an invindex
=head1 DESCRIPTION
Abstract base class for objects which search an invindex. The most prominent
subclass is KinoSearch1::Searcher.
=head1 COPYRIGHT
Copyright 2005-2010 Marvin Humphrey
=head1 LICENSE, DISCLAIMER, BUGS, etc.
See L<KinoSearch1> version 1.00.
=end devdocs
=cut
|