Branch Coverage

blib/lib/ElasticSearch/SearchBuilder.pm
Criterion Covered Total %
branch 210 240 87.5


line true false branch
86 10 2 if @$el
89 105 2 if %$el
98 337 4 if $clause
116 319 973 if ($k =~ /^-./) { }
119 2 43 if $not and $op eq 'cache' || $op eq 'nocache'
122 7 310 if ($op eq 'filter' and $type eq 'query')
124 1 6 if $not
129 0 310 unless my $handler = $self->can("_${type}_unary_$op")
133 31 224 if $not
140 939 10 if $clause
145 914 7 unless $filter
146 2 5 $clause ? :
155 2 1 $type eq 'query' ? :
175 58 2 @$v ? :
178 30 30 $v[0] && ($v[0] eq '-and' || $v[0] eq '-or') ? :
182 30 30 $op ? :
188 14 46 if ($logic ne 'and' and $type eq 'filter')
191 10 20 if defined $_ and not ref $_
193 5 9 if $scalars == @v
197 30 25 if $op
218 329 293 if (my $hash_op = $SPECIAL_OPS{$type}{$op}) { }
222 31 173 if $not
228 2 291 unless $self->can($handler)
232 80 86 if $not
252 171 172 $type eq 'query' ? :
261 34 6 if $type eq 'filter'
274 67 102 $type eq 'filter' ? :
284 23 1537 if @$clauses == 0
285 1323 214 if @$clauses == 1
287 89 125 if ($logic eq 'and')
289 3 70 if @$clauses == 1
291 104 91 if ($type eq 'query')
292 32 72 $logic eq 'and' ? :
309 59 277 if ($type eq 'bool')
311 0 177 ref $_ eq 'HASH' ? :
314 59 0 unless (keys %$clauses)
315 21 38 if ($op eq 'must') { }
16 22 elsif ($op eq 'should') { }
316 5 16 if $must
317 3 18 if $not
318 7 14 unless $should
319 0 14 if (@$should == 1) { }
0 14 elsif (@$queries == 1) { }
330 16 0 unless ($not)
331 8 8 if ($should) { }
0 8 elsif ($must and @$must == 1) { }
332 8 0 unless ($must)
344 5 17 if ($must) { }
345 0 0 if (@$must == 1 and not $should and not $not)
351 15 2 if ($should) { }
2 0 elsif ($not) { }
352 15 0 unless ($not)
367 203 3 if (keys %bool == 1)
369 2 201 if $k ne 'must_not' and @$v == 1
391 53 154 if ($Range_Clauses{$type} and not exists $$_{$type}{'_cache'}) { }
395 16 37 if (defined $merge{$type}{$field}{$op})
446 6 4 unless $v and ref $v eq 'HASH'
451 5 5 $type eq 'query' ? :
470 12 36 $op eq 'or' ? :
498 2 26 unless my $clause = $self->_SWITCH_refkind('Unary -not', $v, {'ARRAYREF', sub { $self->_top_ARRAYREF($type, $v); } , 'HASHREF', sub { $self->_top_HASHREF($type, $v); } , 'SCALAR', sub { croak("$type -not => '${v}' makes little sense, " . "use filter -missing => '${v}' instead"); } , 'UNDEF', sub { croak("$type -not => undef not supported"); } })
512 2 4 unless @$v
516 4 4 $type eq 'query' ? :
518 4 4 unless ref $$p{'values'}
553 2 2 $type eq 'query' ? :
573 2 2 $type eq 'query' ? :
753 1 1 ref $$p{'filters'} eq 'ARRAY' ? :
867 5 0 unless ref $$p{'indices'} eq 'ARRAY'
871 3 2 if ($no)
872 2 1 $no =~ /^(?:all|none)$/ ? :
951 5 0 unless ref $$p{'indices'} eq 'ARRAY'
955 3 2 if ($no)
956 2 1 $no =~ /^(?:all|none)$/ ? :
1052 0 11 unless $filter
1055 3 8 if ($type eq 'query') { }
2 6 elsif ($type eq 'or' or $type eq 'and') { }
1061 2 0 if ref $filters eq 'ARRAY'
1063 9 2 $op eq 'cache' ? :
1077 0 6 unless my $filter = $self->_recurse('filter', $$v{$name})
1080 1 5 if ($type eq 'query')
1115 0 4 unless my $filter = $self->_recurse('filter', shift @v)
1117 0 4 if ($type eq 'query')
1251 0 8 if ref $v eq 'ARRAY' and @$v < 2
1252 0 8 unless defined $v
1255 4 4 if (ref $v eq 'ARRAY')
1267 24 12 if defined $_
1268 4 16 if (@scalars == @$val and @scalars > 1)
1273 0 16 unless my $query = $self->_query_field_terms($k, $op, $_)
1352 1 90 if ($op eq 'range')
1403 58 21 if defined $_
1404 14 29 if (@scalars == @$val and @scalars > 1)
1409 0 50 unless my $filter = $self->_filter_field_terms($k, $op, $_)
1419 3 3 if ref $v eq 'ARRAY' and @$v < 2
1420 0 6 unless defined $v
1423 3 3 if (ref $v eq 'ARRAY')
1441 52 42 if ($es_op = $RANGE_MAP{$op}) { }
1449 0 94 if ($op eq 'range')
1500 3 3 if $op =~ s/^not_//
1506 0 6 if ($op eq 'missing')
1507 3 3 $val ? :
1523 2 4 $val ? :
1614 2 832 if @_
1617 486 14 $clause ? :
1634 227 3716 unless defined $data
1637 0 3716 &Scalar::Util::blessed($data) ? :
1639 1008 2708 unless $ref
1644 0 6 &Scalar::Util::blessed($data) ? :
1645 6 0 if $ref
1656 1235 2708 if $try[0] eq 'SCALAR' or $try[0] eq 'UNDEF'
1669 2293 0 if $method = $self->can($meth_prefix . '_' . $_)
1685 1364 766 if $coderef = $$dispatch_table{$_}
1689 286 1364 unless ($coderef)
1702 4 128 unless ref $val eq 'HASH'
1708 1 141 unless defined $v and length $v
1711 123 4 if ($opt)
1713 64 495 unless exists $$val{$_}
1715 492 3 defined $val && length $val ? :
1719 1 126 if %$val
1731 1 15 unless my $v = delete $$params{$key}
1732 11 4 ref $v eq 'ARRAY' ? :
1734 1 14 unless @queries