line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package KinoSearch1::Search::TermQuery; |
2
|
18
|
|
|
18
|
|
21886
|
use strict; |
|
18
|
|
|
|
|
37
|
|
|
18
|
|
|
|
|
611
|
|
3
|
18
|
|
|
18
|
|
106
|
use warnings; |
|
18
|
|
|
|
|
37
|
|
|
18
|
|
|
|
|
421
|
|
4
|
18
|
|
|
18
|
|
520
|
use KinoSearch1::Util::ToolSet; |
|
18
|
|
|
|
|
52
|
|
|
18
|
|
|
|
|
2535
|
|
5
|
18
|
|
|
18
|
|
99
|
use base qw( KinoSearch1::Search::Query ); |
|
18
|
|
|
|
|
38
|
|
|
18
|
|
|
|
|
1763
|
|
6
|
|
|
|
|
|
|
|
7
|
18
|
|
|
18
|
|
18833
|
use KinoSearch1::Util::ToStringUtils qw( boost_to_string ); |
|
18
|
|
|
|
|
49
|
|
|
18
|
|
|
|
|
1877
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { |
10
|
18
|
|
|
18
|
|
238
|
__PACKAGE__->init_instance_vars( |
11
|
|
|
|
|
|
|
# constructor params / members |
12
|
|
|
|
|
|
|
term => undef, |
13
|
|
|
|
|
|
|
); |
14
|
18
|
|
|
|
|
154
|
__PACKAGE__->ready_get(qw( term )); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init_instance { |
18
|
482
|
|
|
482
|
1
|
717
|
my $self = shift; |
19
|
482
|
50
|
|
|
|
1890
|
confess("parameter 'term' is not a KinoSearch1::Index::Term") |
20
|
|
|
|
|
|
|
unless a_isa_b( $self->{term}, 'KinoSearch1::Index::Term' ); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub create_weight { |
24
|
489
|
|
|
489
|
0
|
927
|
my ( $self, $searcher ) = @_; |
25
|
489
|
|
|
|
|
3022
|
my $weight = KinoSearch1::Search::TermWeight->new( |
26
|
|
|
|
|
|
|
parent => $self, |
27
|
|
|
|
|
|
|
searcher => $searcher, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
12
|
|
|
12
|
0
|
45
|
sub extract_terms { shift->{term} } |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub to_string { |
34
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $proposed_field ) = @_; |
35
|
0
|
|
|
|
|
0
|
my $field = $self->{term}->get_field; |
36
|
0
|
0
|
|
|
|
0
|
my $string = $proposed_field eq $field ? '' : "$field:"; |
37
|
0
|
|
|
|
|
0
|
$string .= $self->{term}->get_text . boost_to_string( $self->{boost} ); |
38
|
0
|
|
|
|
|
0
|
return $string; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub get_similarity { |
43
|
557
|
|
|
557
|
0
|
797
|
my ( $self, $searcher ) = @_; |
44
|
557
|
|
|
|
|
1971
|
my $field_name = $self->{term}->get_field; |
45
|
557
|
|
|
|
|
2056
|
return $searcher->get_similarity($field_name); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
0
|
0
|
0
|
sub equals { shift->todo_death } |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
package KinoSearch1::Search::TermWeight; |
51
|
18
|
|
|
18
|
|
126
|
use strict; |
|
18
|
|
|
|
|
42
|
|
|
18
|
|
|
|
|
560
|
|
52
|
18
|
|
|
18
|
|
101
|
use warnings; |
|
18
|
|
|
|
|
40
|
|
|
18
|
|
|
|
|
560
|
|
53
|
18
|
|
|
18
|
|
119
|
use KinoSearch1::Util::ToolSet; |
|
18
|
|
|
|
|
38
|
|
|
18
|
|
|
|
|
2577
|
|
54
|
18
|
|
|
18
|
|
110
|
use base qw( KinoSearch1::Search::Weight ); |
|
18
|
|
|
|
|
40
|
|
|
18
|
|
|
|
|
2892
|
|
55
|
|
|
|
|
|
|
|
56
|
18
|
|
|
18
|
|
16891
|
use KinoSearch1::Search::TermScorer; |
|
18
|
|
|
|
|
54
|
|
|
18
|
|
|
|
|
11007
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
our %instance_vars = __PACKAGE__->init_instance_vars(); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub init_instance { |
61
|
489
|
|
|
489
|
|
1133
|
my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
489
|
|
|
|
|
2425
|
$self->{similarity} |
64
|
|
|
|
|
|
|
= $self->{parent}->get_similarity( $self->{searcher} ); |
65
|
|
|
|
|
|
|
|
66
|
489
|
|
|
|
|
1940
|
$self->{idf} = $self->{similarity} |
67
|
|
|
|
|
|
|
->idf( $self->{parent}->get_term, $self->{searcher} ); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# kill this because we don't want its baggage. |
70
|
489
|
|
|
|
|
1465
|
undef $self->{searcher}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub scorer { |
74
|
487
|
|
|
487
|
|
910
|
my ( $self, $reader ) = @_; |
75
|
487
|
|
|
|
|
1077
|
my $term = $self->{parent}{term}; |
76
|
487
|
|
|
|
|
1657
|
my $term_docs = $reader->term_docs($term); |
77
|
487
|
50
|
|
|
|
1282
|
return unless defined $term_docs; |
78
|
487
|
100
|
|
|
|
3433
|
return unless $term_docs->get_doc_freq; |
79
|
|
|
|
|
|
|
|
80
|
421
|
|
|
|
|
1370
|
my $norms_reader = $reader->norms_reader( $term->get_field ); |
81
|
421
|
|
|
|
|
4145
|
return KinoSearch1::Search::TermScorer->new( |
82
|
|
|
|
|
|
|
weight => $self, |
83
|
|
|
|
|
|
|
term_docs => $term_docs, |
84
|
|
|
|
|
|
|
similarity => $self->{similarity}, |
85
|
|
|
|
|
|
|
norms_reader => $norms_reader, |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub to_string { |
90
|
0
|
|
|
0
|
|
|
my $self = shift; |
91
|
0
|
|
|
|
|
|
return "weight(" . $self->{parent}->to_string . ")"; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |