| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Interchange::Search::Solr::Builder; |
|
2
|
|
|
|
|
|
|
|
|
3
|
15
|
|
|
15
|
|
633
|
use strict; |
|
|
15
|
|
|
|
|
44
|
|
|
|
15
|
|
|
|
|
480
|
|
|
4
|
15
|
|
|
15
|
|
82
|
use warnings; |
|
|
15
|
|
|
|
|
29
|
|
|
|
15
|
|
|
|
|
419
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
15
|
|
|
15
|
|
637
|
use Moo; |
|
|
15
|
|
|
|
|
15105
|
|
|
|
15
|
|
|
|
|
77
|
|
|
7
|
15
|
|
|
15
|
|
7105
|
use Types::Standard qw/ArrayRef HashRef Int/; |
|
|
15
|
|
|
|
|
76802
|
|
|
|
15
|
|
|
|
|
159
|
|
|
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
|
72
|
my $self = shift; |
|
87
|
|
|
|
|
|
|
|
|
88
|
1
|
|
|
|
|
3
|
my @fragments; |
|
89
|
1
|
50
|
|
|
|
2
|
if (@{$self->terms}) { |
|
|
1
|
|
|
|
|
26
|
|
|
90
|
1
|
|
|
|
|
11
|
push @fragments, 'words', @{$self->terms}; |
|
|
1
|
|
|
|
|
17
|
|
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
1
|
50
|
|
|
|
8
|
if (%{$self->filters}) { |
|
|
1
|
|
|
|
|
19
|
|
|
94
|
1
|
|
|
|
|
10
|
foreach my $facet (@{ $self->facets }) { |
|
|
1
|
|
|
|
|
19
|
|
|
95
|
2
|
100
|
|
|
|
46
|
if (my $terms = $self->filters->{$facet}) { |
|
96
|
1
|
|
|
|
|
10
|
push @fragments, $facet, @$terms; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
} |
|
100
|
1
|
50
|
33
|
|
|
19
|
if ($self->page and $self->page > 1) { |
|
101
|
1
|
|
|
|
|
48
|
push @fragments, page => $self->page; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
1
|
|
|
|
|
25
|
return join ('/', @fragments); |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |