| 1 | package Catmandu::Store::Solr::Searcher; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use Catmandu::Sane; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 3 | our $VERSION = "0.0304"; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | with 'Catmandu::Iterable'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 3 | has bag => (is => 'ro', required => 1); | |||||||||||||||||||||||||||
| 11 | 3 | has query => (is => 'ro', required => 1); | |||||||||||||||||||||||||||
| 12 | 3 | has start => (is => 'ro', required => 1); | |||||||||||||||||||||||||||
| 13 | 3 | has limit => (is => 'ro', required => 1); | |||||||||||||||||||||||||||
| 14 | 3 | has sort => (is => 'ro', required => 0); | |||||||||||||||||||||||||||
| 15 | 3 | has total => (is => 'ro'); | |||||||||||||||||||||||||||
| 16 | 0 | ▶ | has fl => (is => 'ro', lazy => 1, default => sub {"*"}); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub generator { | ||||||||||||||||||||||||||
|
Subroutine
generator: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 20 | 0 | my $store = $self->bag->store; | |||||||||||||||||||||||||||
| 21 | 0 | my $name = $self->bag->name; | |||||||||||||||||||||||||||
| 22 | 0 | my $limit = $self->limit; | |||||||||||||||||||||||||||
| 23 | 0 | my $query = $self->query; | |||||||||||||||||||||||||||
| 24 | 0 | my $bag_field = $self->bag->bag_field; | |||||||||||||||||||||||||||
| 25 | 0 | my $fq = qq/{!type=lucene}$bag_field:"$name"/; | |||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||
| 27 | 0 | state $start = $self->start; | |||||||||||||||||||||||||||
| 28 | 0 | state $total = $self->total; | |||||||||||||||||||||||||||
| 29 | 0 | state $hits; | |||||||||||||||||||||||||||
| 30 | 0 | ▶ | if (defined $total) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | return unless $total; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | 0 | ▶ | unless ($hits && @$hits) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$hits and @$hits
MC/DC0%0/2
$hits and @$hits
$hits
@$hits
Truth table0%0/3
A and B
A= $hitsB= @$hits
| |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if ($total && $limit > $total) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$total and $limit > $total
MC/DC0%0/2
$total and $limit > $total
$total
$limit > $total
Truth table0%0/3
A and B
A= $totalB= $limit > $total
| |||||||||||||||||||||||||||||
| 35 | 0 | $limit = $total; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | $hits = $store->solr->search( | ||||||||||||||||||||||||||||
| 38 | $query, | ||||||||||||||||||||||||||||
| 39 | { | ||||||||||||||||||||||||||||
| 40 | start => $start, | ||||||||||||||||||||||||||||
| 41 | rows => $limit, | ||||||||||||||||||||||||||||
| 42 | fq => $fq, | ||||||||||||||||||||||||||||
| 43 | sort => $self->sort, | ||||||||||||||||||||||||||||
| 44 | fl => $self->fl, | ||||||||||||||||||||||||||||
| 45 | facet => "false", | ||||||||||||||||||||||||||||
| 46 | spellcheck => "false" | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | 0 | )->content->{response}{docs}; | |||||||||||||||||||||||||||
| 49 | 0 | $start += $limit; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ($total) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | $total--; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my $hit = shift(@$hits) || return; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift @$hits || (return)
MC/DC0%0/1
shift @$hits || (return)
shift @$hits
Truth table0%0/2
A
A= shift @$hits
| |||||||||||||||||||||||||||||
| 55 | 0 | $self->bag->map_fields($hit); | |||||||||||||||||||||||||||
| 56 | 0 | $hit; | |||||||||||||||||||||||||||
| 57 | 0 | }; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub slice { | ||||||||||||||||||||||||||
|
Subroutine
slice: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | 0 | my ($self, $start, $total) = @_; | |||||||||||||||||||||||||||
| 62 | 0 | ▶ | $start //= 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$start //= 0
MC/DC0%0/1
$start //= 0
$start
Truth table0%0/2
A
A= $start
| |||||||||||||||||||||||||||||
| 63 | 0 | $self->new( | |||||||||||||||||||||||||||
| 64 | bag => $self->bag, | ||||||||||||||||||||||||||||
| 65 | query => $self->query, | ||||||||||||||||||||||||||||
| 66 | start => $self->start + $start, | ||||||||||||||||||||||||||||
| 67 | limit => $self->limit, | ||||||||||||||||||||||||||||
| 68 | sort => $self->sort, | ||||||||||||||||||||||||||||
| 69 | total => $total, | ||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub count { | ||||||||||||||||||||||||||
|
Subroutine
count: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 74 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 75 | 0 | my $name = $self->bag->name; | |||||||||||||||||||||||||||
| 76 | 0 | my $bag_field = $self->bag->bag_field; | |||||||||||||||||||||||||||
| 77 | 0 | my $res = $self->bag->store->solr->search( | |||||||||||||||||||||||||||
| 78 | $self->query, | ||||||||||||||||||||||||||||
| 79 | { | ||||||||||||||||||||||||||||
| 80 | rows => 0, | ||||||||||||||||||||||||||||
| 81 | fq => qq/{!type=lucene}$bag_field:"$name"/, | ||||||||||||||||||||||||||||
| 82 | facet => "false", | ||||||||||||||||||||||||||||
| 83 | spellcheck => "false" | ||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||
| 86 | 0 | $res->content->{response}{numFound}; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 3 | 1; | |||||||||||||||||||||||||||