line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dezi::Test::Searcher; |
2
|
2
|
|
|
2
|
|
4456
|
use Moose; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
16
|
|
3
|
|
|
|
|
|
|
extends 'Dezi::Searcher'; |
4
|
2
|
|
|
2
|
|
13642
|
use Types::Standard qw( InstanceOf ); |
|
2
|
|
|
|
|
66777
|
|
|
2
|
|
|
|
|
23
|
|
5
|
2
|
|
|
2
|
|
1513
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
126
|
|
6
|
2
|
|
|
2
|
|
10
|
use Data::Dump qw( dump ); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
93
|
|
7
|
2
|
|
|
2
|
|
12
|
use Scalar::Util qw( blessed ); |
|
2
|
|
|
|
|
20
|
|
|
2
|
|
|
|
|
97
|
|
8
|
2
|
|
|
2
|
|
1202
|
use Dezi::Searcher::SearchOpts; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
83
|
|
9
|
2
|
|
|
2
|
|
1567
|
use Dezi::Test::Results; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
84
|
|
10
|
2
|
|
|
2
|
|
1584
|
use Dezi::Test::ResultsPayload; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
1005
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# need this to build property_map |
13
|
|
|
|
|
|
|
has 'swish3_config' => |
14
|
|
|
|
|
|
|
( is => 'rw', isa => InstanceOf ['SWISH::3::Config'], required => 1, ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _cache_property_map { |
17
|
0
|
|
|
0
|
|
|
my $self = shift; |
18
|
0
|
|
|
|
|
|
my %prop_map; |
19
|
0
|
|
|
|
|
|
my $props = $self->swish3_config->get_properties; |
20
|
0
|
|
|
|
|
|
for my $name ( @{ $props->keys } ) { |
|
0
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my $prop = $props->get($name); |
22
|
0
|
|
|
|
|
|
my $alias = $prop->alias_for; |
23
|
0
|
0
|
|
|
|
|
if ($alias) { |
24
|
0
|
|
|
|
|
|
$prop_map{$name} = $alias; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
0
|
|
|
|
|
|
$self->{property_map} = \%prop_map; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
1
|
|
sub invindex_class {'Dezi::Test::InvIndex'} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub search { |
33
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
34
|
0
|
|
|
|
|
|
my ( $query, $opts ) = @_; |
35
|
0
|
0
|
|
|
|
|
if ($opts) { |
36
|
0
|
|
|
|
|
|
$opts = $self->_coerce_search_opts($opts); |
37
|
|
|
|
|
|
|
} |
38
|
0
|
0
|
|
|
|
|
if ( !defined $query ) { |
|
|
0
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
confess "query required"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
elsif ( !blessed($query) ) { |
42
|
0
|
0
|
|
|
|
|
$query = $self->qp->parse($query) |
43
|
|
|
|
|
|
|
or confess "Invalid query: " . $self->qp->error; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#dump $self->invindex; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $hits = $self->invindex->[0]->search($query); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# sort by number of matches per doc |
51
|
0
|
|
|
|
|
|
my @urls; |
52
|
|
|
|
|
|
|
my %scores; |
53
|
0
|
|
|
|
|
|
for my $url ( sort { $hits->{$b} <=> $hits->{$a} } keys %$hits ) { |
|
0
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
push @urls, $url; |
55
|
0
|
|
|
|
|
|
$scores{$url} = $hits->{$url}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# look up the doc object for each hit |
59
|
0
|
|
|
|
|
|
my @docs; |
60
|
0
|
|
|
|
|
|
for my $url (@urls) { |
61
|
0
|
|
|
|
|
|
push @docs, $self->invindex->[0]->get_doc($url); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#dump $self->invindex->[0]; |
65
|
0
|
|
|
|
|
|
my $results = Dezi::Test::Results->new( |
66
|
|
|
|
|
|
|
query => $query, |
67
|
|
|
|
|
|
|
hits => scalar(@urls), |
68
|
|
|
|
|
|
|
payload => Dezi::Test::ResultsPayload->new( |
69
|
|
|
|
|
|
|
docs => \@docs, |
70
|
|
|
|
|
|
|
urls => \@urls, |
71
|
|
|
|
|
|
|
scores => \%scores, |
72
|
|
|
|
|
|
|
), |
73
|
|
|
|
|
|
|
property_map => $self->property_map, |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
#dump $results; |
77
|
0
|
|
|
|
|
|
return $results; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 NAME |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Dezi::Test::Searcher - test searcher class |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 METHODS |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 swish3_config |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns instance of L<SWISH::3::Config>. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 invindex_class |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns C<Dezi::Test::InvIndex>. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 search( I<query>, I<opts> ) |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Returns L<Dezi::Test::Results>. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 AUTHOR |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Peter Karman, E<lt>karpet@dezi.orgE<gt> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 BUGS |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-dezi-app at rt.cpan.org>, or through |
109
|
|
|
|
|
|
|
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dezi-App>. |
110
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SUPPORT |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
perldoc Dezi::App |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
You can also look for information at: |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=over 4 |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item * Website |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L<http://dezi.org/> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * IRC |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
#dezisearch at freenode |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * Mailing list |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
L<https://groups.google.com/forum/#!forum/dezi-search> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dezi-App> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Dezi-App> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * CPAN Ratings |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Dezi-App> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * Search CPAN |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
L<https://metacpan.org/dist/Dezi-App/> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=back |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Copyright 2014 by Peter Karman |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
157
|
|
|
|
|
|
|
it under the terms of the GPL v2 or later. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 SEE ALSO |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
L<http://dezi.org/>, L<http://swish-e.org/>, L<http://lucy.apache.org/> |
162
|
|
|
|
|
|
|
|