line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Interchange::Search::Solr::Builder; |
2
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
544
|
use strict; |
|
14
|
|
|
|
|
36
|
|
|
14
|
|
|
|
|
402
|
|
4
|
14
|
|
|
14
|
|
74
|
use warnings; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
400
|
|
5
|
|
|
|
|
|
|
|
6
|
14
|
|
|
14
|
|
601
|
use Moo; |
|
14
|
|
|
|
|
13895
|
|
|
14
|
|
|
|
|
66
|
|
7
|
14
|
|
|
14
|
|
5968
|
use Types::Standard qw/ArrayRef HashRef Int/; |
|
14
|
|
|
|
|
73074
|
|
|
14
|
|
|
|
|
132
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Interchange::Search::Solr::Builder |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
L<WebService::Solr::Response> subclass for building url. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 ACCESSORS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 terms |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
An arrayref contains search terms |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has terms => ( |
26
|
|
|
|
|
|
|
is => 'rw', |
27
|
|
|
|
|
|
|
isa => ArrayRef |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 filters |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
A hashref which key is a feild of data and the value is keyword |
33
|
|
|
|
|
|
|
that needs to filter. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has filters => ( |
38
|
|
|
|
|
|
|
is => 'rw', |
39
|
|
|
|
|
|
|
isa => HashRef |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 facets |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
A string or an arrayref with the fields which will generate a facet. |
45
|
|
|
|
|
|
|
Defaults to |
46
|
|
|
|
|
|
|
[qw/suchbegriffe manufacturer/] |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has facets => ( |
51
|
|
|
|
|
|
|
is => 'rw', |
52
|
|
|
|
|
|
|
isa => ArrayRef, |
53
|
|
|
|
|
|
|
default => sub { |
54
|
|
|
|
|
|
|
return [qw/suchbegriffe manufacturer/]; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 page |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
A number of page and must be positive number (>= 1) |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has page => ( |
65
|
|
|
|
|
|
|
is => 'rw', |
66
|
|
|
|
|
|
|
isa => sub { |
67
|
|
|
|
|
|
|
if (defined $_[0]){ |
68
|
|
|
|
|
|
|
die "$_[0] is not integer" if $_[0] !~ /^\d+$/; |
69
|
|
|
|
|
|
|
die "must be positive number" unless $_[0] >= 1 |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 METHODS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
In addition to all the L<WebService::Solr::Response> methods this |
77
|
|
|
|
|
|
|
class have the following methods: |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 url_builder; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Build a query url with the parameter passed |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub url_builder { |
86
|
1
|
|
|
1
|
1
|
31
|
my $self = shift; |
87
|
|
|
|
|
|
|
|
88
|
1
|
|
|
|
|
2
|
my @fragments; |
89
|
1
|
50
|
|
|
|
2
|
if (@{$self->terms}) { |
|
1
|
|
|
|
|
20
|
|
90
|
1
|
|
|
|
|
13
|
push @fragments, 'words', @{$self->terms}; |
|
1
|
|
|
|
|
17
|
|
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
1
|
50
|
|
|
|
11
|
if (%{$self->filters}) { |
|
1
|
|
|
|
|
21
|
|
94
|
1
|
|
|
|
|
12
|
foreach my $facet (@{ $self->facets }) { |
|
1
|
|
|
|
|
17
|
|
95
|
2
|
100
|
|
|
|
55
|
if (my $terms = $self->filters->{$facet}) { |
96
|
1
|
|
|
|
|
11
|
push @fragments, $facet, @$terms; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
1
|
50
|
33
|
|
|
18
|
if ($self->page and $self->page > 1) { |
101
|
1
|
|
|
|
|
54
|
push @fragments, page => $self->page; |
102
|
|
|
|
|
|
|
} |
103
|
1
|
|
|
|
|
43
|
return join ('/', @fragments); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |