| 1 | package Search::OpenSearch::Engine; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | use Types::Standard | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | qw( Str Num Int ArrayRef HashRef InstanceOf Maybe Object Bool ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Search::OpenSearch::Types qw( SOSFacets ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Search::OpenSearch::Facets; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Search::OpenSearch::Response::XML; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Search::OpenSearch::Response::JSON; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Search::OpenSearch::Response::ExtJS; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Search::OpenSearch::Response::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Search::Tools::XML; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Search::Tools::UTF8; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Search::Tools; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use CHI; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use Time::HiRes qw( time ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use Data::Dump qw( dump ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use JSON; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | has 'index' => ( is => 'rw', isa => ArrayRef, ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | has 'facets' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | isa => Maybe [SOSFacets], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | coerce => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | has 'fields' => ( is => 'rw', isa => Maybe [ArrayRef], ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | has 'link' => ( is => 'rw', isa => Str, builder => 'init_link' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | has 'cache' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | isa => Maybe [Object], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | builder => 'init_cache', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | has 'cache_ttl' => ( is => 'rw', isa => Int, builder => 'init_cache_ttl' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | has 'cache_ok' => ( is => 'rw', isa => Bool, builder => 'init_cache_ok' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | has 'do_not_hilite' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | ( is => 'rw', isa => HashRef, lazy => 1, default => sub { {} } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | has 'searcher' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | isa => Maybe [Object], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | builder => 'init_searcher' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | has 'indexer' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | isa => Maybe [Object], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | builder => 'init_indexer' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | has 'suggester' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | isa => Maybe [Object], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | builder => 'init_suggester', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | has 'snipper_config' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | isa => HashRef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | builder => 'init_snipper_config' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | has 'hiliter_config' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | isa => HashRef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | builder => 'init_hiliter_config' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | has 'parser_config' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | isa => HashRef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | builder => 'init_parser_config' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | has 'indexer_config' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | isa => HashRef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | builder => 'init_indexer_config' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | has 'searcher_config' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | isa => HashRef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | builder => 'init_searcher_config' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | has 'suggester_config' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | isa => HashRef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | builder => 'init_suggester_config' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | has 'logger' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | isa => Maybe [Object], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | builder => 'init_logger' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | has 'debug' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | ( is => 'rw', isa => Bool, default => sub { $ENV{SOS_DEBUG} || 0 } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | has 'error' => ( is => 'rw', isa => Maybe [Str], ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | has 'array_field_values' => ( is => 'rw', isa => Bool, default => sub {1} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | has 'response_version' => ( is => 'rw', isa => Str, builder => 'version' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | has 'default_response_format' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | isa => Maybe [Str], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | builder => 'init_default_response_format', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | has 'cache_key_seed' => | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | ( is => 'rw', isa => Maybe [Str], builder => 'init_cache_key_seed' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | our $VERSION = '0.409'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | sub version { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: not called CC=2 SCAR=11.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | my $class = ref $self ? ref($self) : $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | return ${"${class}::VERSION"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | sub init_cache_ttl { 60 * 60 } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_cache_ttl: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | sub init_cache_ok {1} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_cache_ok: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | sub init_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_cache: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | return unless $self->cache_ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | return CHI->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | driver => 'File', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | dir_create_mode => 0770, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | file_create_mode => 0660, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | root_dir => "/tmp/opensearch_cache", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | sub init_snipper_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_snipper_config: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | return { as_sentences => 1, strip_markup => 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub init_hiliter_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_hiliter_config: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | return { class => 'h', tag => 'b' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | sub init_parser_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_parser_config: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | return {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub init_indexer_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_indexer_config: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub init_searcher_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_searcher_config: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | return {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub init_suggester_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_suggester_config: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | return {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub init_link {''} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_link: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | sub init_searcher { confess "$_[0] does not implement init_searcher()" } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_searcher: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub init_indexer { confess "$_[0] does not implement init_indexer()" } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_indexer: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | sub type { confess "$_[0] does not implement type()" } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | sub has_rest_api {0} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_rest_api: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sub get_allowed_http_methods { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_allowed_http_methods: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | confess "$_[0] does not implement get_allowed_http_methods"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | sub init_default_response_format {'XML'} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_default_response_format: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub init_cache_key_seed {'search-opensearch-engine'} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_cache_key_seed: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | sub search { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search: not called CC=34 SCAR=70.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my $query = $args{'q'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | confess "query required" unless defined $query; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my $start_time = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | my $offset = $args{'o'} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'o'} || 0
MC/DC0%0/1
$args{'o'} || 0
$args{'o'}
Truth table0%0/2
A
A= $args{'o'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | my $sort_by = $args{'s'} || 'score DESC'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'s'} || 'score DESC'
MC/DC0%0/1
$args{'s'} || 'score DESC'
$args{'s'}
Truth table0%0/2
A
A= $args{'s'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | my $page_size = $args{'p'} || 25; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'p'} || 25
MC/DC0%0/1
$args{'p'} || 25
$args{'p'}
Truth table0%0/2
A
A= $args{'p'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my $apply_hilite = $args{'h'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | $apply_hilite = 1 unless defined $apply_hilite; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | my $count_only = $args{'c'} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'c'} || 0
MC/DC0%0/1
$args{'c'} || 0
$args{'c'}
Truth table0%0/2
A
A= $args{'c'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | my $limits = $args{'L'} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'L'} || []
MC/DC0%0/1
$args{'L'} || []
$args{'L'}
Truth table0%0/2
A
A= $args{'L'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | my $boolop = $args{'b'} || 'AND'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'b'} || 'AND'
MC/DC0%0/1
$args{'b'} || 'AND'
$args{'b'}
Truth table0%0/2
A
A= $args{'b'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my $include_results = $args{'r'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | $include_results = 1 unless defined $include_results; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $include_facets = $args{'f'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | $include_facets = 1 unless defined $include_facets; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | my $response_fields = $args{'x'} || $self->fields; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$args{'x'} || $self->fields
MC/DC0%0/2
$args{'x'} || $self->fields
$args{'x'}
$self->fields
Truth table0%0/3
A || B
A= $args{'x'}B= $self->fields
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | if ( $self->debug and $self->logger ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->debug and $self->logger
MC/DC0%0/2
$self->debug and $self->logger
$self->debug
$self->logger
Truth table0%0/3
A and B
A= $self->debugB= $self->logger
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $self->logger->log( dump( \%args ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | my $format | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | = $args{'t'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | || $args{'format'} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$args{'t'} || $args{'format'} || $self->default_response_format
$args{"t"} or $args{"format"}
MC/DC0%0/3
$args{'t'} || $args{'format'} || $self->default_response_format
$args{"t"}
$args{"format"}
$self->default_response_format
Truth table0%0/4
A or B || C
A= $args{"t"}B= $args{"format"}C= $self->default_response_format
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | || $self->default_response_format; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # backwards compat | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | if ( $format eq 'xml' or $format eq 'json' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$format eq "xml" or $format eq "json"
MC/DC0%0/2
$format eq "xml" or $format eq "json"
$format eq "xml"
$format eq "json"
Truth table0%0/3
A or B
A= $format eq "xml"B= $format eq "json"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $format = uc($format); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | my $response_class = $args{response_class} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | || 'Search::OpenSearch::Response::' . $format; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'response_class'} || 'Search::OpenSearch::Response::' . $format
MC/DC0%0/1
$args{'response_class'} || 'Search::OpenSearch::Response::' . $format
$args{'response_class'}
Truth table0%0/2
A
A= $args{'response_class'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if ( !ref($limits) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $limits = [ split( m/,/, $limits ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my @limits; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | for my $limit (@$limits) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my ( $field, $low, $high ) = split( m/\|/, $limit ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $range = $self->set_limit( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | field => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | lower => $low, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | upper => $high, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | push @limits, $range; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | my $searcher = $self->searcher or croak "searcher not defined"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $results = $searcher->search( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | to_utf8("$query"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | { start => $offset, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | max => $page_size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | order => $sort_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | limit => \@limits, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | default_boolop => $boolop, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $search_time = sprintf( "%0.5f", time() - $start_time ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | my $start_build = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my $res_query = $results->query; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | my $query_tree = $res_query->tree; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | if ( $self->debug and $self->logger ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->debug and $self->logger
MC/DC0%0/2
$self->debug and $self->logger
$self->debug
$self->logger
Truth table0%0/3
A and B
A= $self->debugB= $self->logger
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $self->logger->log( dump $query_tree ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | my $response = $response_class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | debug => $self->debug, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | total => $results->hits, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | json_query => to_json($query_tree), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | parsed_query => $res_query->stringify, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | query => to_utf8($query), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | search_time => $search_time, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | link => ( $args{'u'} || $args{'link'} || $self->link ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$args{'u'} || $args{'link'} || $self->link
$args{"u"} or $args{"link"}
$self->response_version || $self->version
MC/DC0%0/3
$args{'u'} || $args{'link'} || $self->link
$args{"u"}
$args{"link"}
$self->link
MC/DC0%0/2
$self->response_version || $self->version
$self->response_version
$self->version
Truth table0%0/4
A or B || C
A= $args{"u"}B= $args{"link"}C= $self->link
Truth table0%0/3
A || B
A= $self->response_versionB= $self->version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | version => ( $self->response_version || $self->version ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | engine => blessed($self) . ' ' . $self->version(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | sort_info => $sort_by, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | if ( $self->suggester ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $response->suggestions( $self->suggester->suggest("$query") ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | if ( $self->debug and $self->logger ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->debug and $self->logger
MC/DC0%0/2
$self->debug and $self->logger
$self->debug
$self->logger
Truth table0%0/3
A and B
A= $self->debugB= $self->logger
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $self->logger->log( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | "include_results=$include_results include_facets=$include_facets count_only=$count_only" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $self->logger->log( "response_fields=" . dump($response_fields) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if ( $include_results && !$count_only ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$include_results and not $count_only
MC/DC0%0/2
$include_results and not $count_only
$include_results
not $count_only
Truth table0%0/3
A and not(B)
A= $include_resultsB= not $count_only
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $response->fields($response_fields); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $response->offset($offset); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $response->page_size($page_size); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $response->results( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | $self->build_results( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | fields => $response_fields, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | results => $results, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | page_size => $page_size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | apply_hilite => $apply_hilite, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | query => $query, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | args => \%args, # original args | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | if ( $include_facets && !$count_only ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$include_facets and not $count_only
MC/DC0%0/2
$include_facets and not $count_only
$include_facets
not $count_only
Truth table0%0/3
A and not(B)
A= $include_facetsB= not $count_only
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $response->facets( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | $self->get_facets( to_utf8($query), $results, \%args ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my $build_time = sprintf( "%0.5f", time() - $start_build ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $response->build_time($build_time); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | return $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | sub set_limit { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_limit: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | my @range = ( $args{field}, $args{lower}, $args{upper} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | return \@range; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | sub get_facets_cache_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_facets_cache_key: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my ( $query, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | return sprintf( "%s.%s.%s", $self->cache_key_seed(), ref($self), $query ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | sub get_facets { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_facets: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my $query = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my $results = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | my $cache_key = $self->get_facets_cache_key( $query, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | my $cache = $self->cache or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | my $facets; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | if ( $cache->get($cache_key) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | if ( $self->debug and $self->logger ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->debug and $self->logger
MC/DC0%0/2
$self->debug and $self->logger
$self->debug
$self->logger
Truth table0%0/3
A and B
A= $self->debugB= $self->logger
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $self->logger->log("get facets for '$cache_key' from cache"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $facets = $cache->get($cache_key); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if ( $self->debug and $self->logger ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->debug and $self->logger
MC/DC0%0/2
$self->debug and $self->logger
$self->debug
$self->logger
Truth table0%0/3
A and B
A= $self->debugB= $self->logger
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $self->logger->log("build facets for '$cache_key'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $facets = $self->build_facets( $query, $results, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $cache->set( $cache_key, $facets, $self->cache_ttl ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | return $facets; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | sub build_facets { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_facets: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | croak ref(shift) . " must implement build_facets()"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | sub build_results { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_results: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | my $fields = $args{fields} || $self->fields || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$args{'fields'} || $self->fields || []
$args{"fields"} or $self->fields
MC/DC0%0/2
$args{'fields'} || $self->fields || []
$args{"fields"}
$self->fields
Truth table0%0/3
A or B
A= $args{"fields"}B= $self->fields
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | my $results = $args{results} or croak "no results defined"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | my $page_size = $args{page_size} || 25; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'page_size'} || 25
MC/DC0%0/1
$args{'page_size'} || 25
$args{'page_size'}
Truth table0%0/2
A
A= $args{'page_size'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my $q = $args{query}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | confess "query required" unless defined $q; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my @results; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | my %snipper_config = %{ $self->snipper_config }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my %hiliter_config = %{ $self->hiliter_config }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my %parser_config = %{ $self->parser_config }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my $XMLer = Search::Tools::XML->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my $query = Search::Tools->parser(%parser_config)->parse($q); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my $snipper = Search::Tools->snipper( query => $query, %snipper_config ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my $hiliter = Search::Tools->hiliter( query => $query, %hiliter_config ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | while ( my $result = $results->next ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | push @results, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | $self->process_result( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | result => $result, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | hiliter => $hiliter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | snipper => $snipper, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | XMLer => $XMLer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | fields => $fields, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | apply_hilite => $args{apply_hilite}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | args => \%args, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | last if ++$count >= $page_size; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | return \@results; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub process_result { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_result: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my ( $self, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my $result = $args{result}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my $hiliter = $args{hiliter}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my $XMLer = $args{XMLer}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my $snipper = $args{snipper}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | my $fields = $args{fields}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my $apply_hilite = $args{apply_hilite}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | my $title = $XMLer->escape( $result->title || '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$result->title || ''
MC/DC0%0/1
$result->title || ''
$result->title
Truth table0%0/2
A
A= $result->title
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | # escape the summary *after* we snip it | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | my $summary = $result->summary || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$result->summary || ''
MC/DC0%0/1
$result->summary || ''
$result->summary
Truth table0%0/2
A
A= $result->summary
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | # \003 is the record-delimiter in Swish3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | # the default behaviour is just to ignore it | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | # and replace with a single space, but a subclass (like JSON) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | # might want to split on it to get an array of values | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | $title =~ s/\003/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | $summary =~ s/\003/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my %res = ( score => $result->score, ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | for my $field (@$fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | my $str = $result->get_property($field) || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$result->get_property($field) || ''
MC/DC0%0/1
$result->get_property($field) || ''
$result->get_property($field)
Truth table0%0/2
A
A= $result->get_property($field)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | if ( $self->array_field_values ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | if ( !$apply_hilite or $self->no_hiliting($field) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $apply_hilite or $self->no_hiliting($field)
MC/DC0%0/2
not $apply_hilite or $self->no_hiliting($field)
not $apply_hilite
$self->no_hiliting($field)
Truth table0%0/3
not(A) or B
A= not $apply_hiliteB= $self->no_hiliting($field)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | $res{$field} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | = [ map { $XMLer->escape($_) } split( m/\003/, $str ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | $res{$field} = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | $hiliter->light( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | $XMLer->escape( $snipper->snip($_) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | split( m/\003/, $str ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $str =~ s/\003/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | if ( !$apply_hilite or $self->no_hiliting($field) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $apply_hilite or $self->no_hiliting($field)
MC/DC0%0/2
not $apply_hilite or $self->no_hiliting($field)
not $apply_hilite
$self->no_hiliting($field)
Truth table0%0/3
not(A) or B
A= not $apply_hiliteB= $self->no_hiliting($field)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $res{$field} = $XMLer->escape($str); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $res{$field} = $hiliter->light( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | $XMLer->escape( $snipper->snip($str) ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # set the reserved fields *after* we loop fields, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | # so that the reserved fields are always strings. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | $res{uri} = $result->uri; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $res{mtime} = $result->mtime; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | $res{title} = ( $apply_hilite ? $hiliter->light($title) : $title ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | $res{summary} = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | $apply_hilite | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | ? $hiliter->light( $XMLer->escape( $snipper->snip($summary) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | : $XMLer->escape($summary) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | return \%res; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | sub no_hiliting { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
no_hiliting: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my ( $self, $field ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | return $self->{do_not_hilite}->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||