line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package KinoSearch1::Search::Searchable; |
2
|
18
|
|
|
18
|
|
110
|
use strict; |
|
18
|
|
|
|
|
36
|
|
|
18
|
|
|
|
|
574
|
|
3
|
18
|
|
|
18
|
|
97
|
use warnings; |
|
18
|
|
|
|
|
44
|
|
|
18
|
|
|
|
|
406
|
|
4
|
18
|
|
|
18
|
|
97
|
use KinoSearch1::Util::ToolSet; |
|
18
|
|
|
|
|
61
|
|
|
18
|
|
|
|
|
2762
|
|
5
|
18
|
|
|
18
|
|
104
|
use base qw( KinoSearch1::Util::Class ); |
|
18
|
|
|
|
|
42
|
|
|
18
|
|
|
|
|
3947
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
18
|
|
|
18
|
|
178
|
__PACKAGE__->init_instance_vars( |
9
|
|
|
|
|
|
|
# members |
10
|
|
|
|
|
|
|
similarity => undef, |
11
|
|
|
|
|
|
|
field_sims => undef, # {} |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
18
|
|
|
18
|
|
5167
|
use KinoSearch1::Search::Similarity; |
|
18
|
|
|
|
|
38
|
|
|
18
|
|
|
|
|
6723
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=begin comment |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $hits = $searchable->search($query_string); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $hits = $searchable->search( |
22
|
|
|
|
|
|
|
query => $query, |
23
|
|
|
|
|
|
|
filter => $filter, |
24
|
|
|
|
|
|
|
sort_spec => $sort_spec, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=end comment |
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
0
|
0
|
sub search { shift->abstract_death } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=begin comment |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $explanation = $searchable->explain( $weight, $doc_num ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Provide an Explanation for how the document represented by $doc_num scored |
37
|
|
|
|
|
|
|
agains $weight. Useful for probing the guts of Similarity. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=end comment |
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
0
|
0
|
0
|
sub explain { shift->todo_death } |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=begin comment |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $doc_num = $searchable->max_doc; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Return one larger than the largest doc_num. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=end comment |
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
0
|
0
|
0
|
sub max_doc { shift->abstract_death } |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=begin comment |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $doc = $searchable->fetch_doc($doc_num); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Generate a Doc object, retrieving the stored fields from the invindex. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=end comment |
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
0
|
0
|
0
|
sub fetch_doc { shift->abstract_death } |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=begin comment |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $doc_freq = $searchable->doc_freq($term); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Return the number of documents which contain this Term. Used for calculating |
71
|
|
|
|
|
|
|
Weights. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=end comment |
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
0
|
0
|
0
|
sub doc_freq { shift->abstract_death } |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=begin comment |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
$searchable->set_similarity($sim); |
81
|
|
|
|
|
|
|
$searchable->set_similarity( $field_name, $alternate_sim ); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $sim = $searchable->get_similarity; |
84
|
|
|
|
|
|
|
my $alt_sim = $searchable->get_similarity($field_name); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Set or get Similarity. If a field name is included, set/retrieve the |
87
|
|
|
|
|
|
|
Similarity instance for that field only. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=end comment |
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub set_similarity { |
93
|
1
|
50
|
|
1
|
0
|
14
|
if ( @_ == 3 ) { |
94
|
1
|
|
|
|
|
3
|
my ( $self, $field_name, $sim ) = @_; |
95
|
1
|
|
|
|
|
4
|
$self->{field_sims}{$field_name} = $sim; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
else { |
98
|
0
|
|
|
|
|
0
|
$_[0]->{similarity} = $_[1]; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub get_similarity { |
103
|
1099
|
|
|
1099
|
0
|
2673
|
my ( $self, $field_name ) = @_; |
104
|
1099
|
100
|
100
|
|
|
5249
|
if ( defined $field_name and exists $self->{field_sims}{$field_name} ) { |
105
|
1
|
|
|
|
|
4
|
return $self->{field_sims}{$field_name}; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
else { |
108
|
1098
|
|
|
|
|
5299
|
return $self->{similarity}; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# not sure these are needed (call $query->create_weight($searcher) instead) |
113
|
0
|
|
|
0
|
0
|
0
|
sub create_weight { shift->unimplemented_death } |
114
|
0
|
|
|
0
|
0
|
0
|
sub rewrite_query { shift->unimplemented_death } |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub doc_freqs { |
117
|
7
|
|
|
7
|
0
|
13
|
my ( $self, $terms ) = @_; |
118
|
7
|
|
|
|
|
13
|
my @doc_freqs = map { $self->doc_freq($_) } @$terms; |
|
7
|
|
|
|
|
27
|
|
119
|
7
|
|
|
|
|
50
|
return \@doc_freqs; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
0
|
0
|
|
sub close { } |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
__END__ |