Lines 51-56
use Koha::Exceptions::Elasticsearch;
Link Here
|
51 |
use MARC::Record; |
51 |
use MARC::Record; |
52 |
use MARC::File::XML; |
52 |
use MARC::File::XML; |
53 |
use MIME::Base64 qw( decode_base64 ); |
53 |
use MIME::Base64 qw( decode_base64 ); |
|
|
54 |
use JSON; |
54 |
|
55 |
|
55 |
Koha::SearchEngine::Elasticsearch::Search->mk_accessors(qw( store )); |
56 |
Koha::SearchEngine::Elasticsearch::Search->mk_accessors(qw( store )); |
56 |
|
57 |
|
Lines 93-104
sub search {
Link Here
|
93 |
my $results = eval { |
94 |
my $results = eval { |
94 |
$elasticsearch->search( |
95 |
$elasticsearch->search( |
95 |
index => $self->index_name, |
96 |
index => $self->index_name, |
|
|
97 |
track_total_hits => JSON::true, |
96 |
body => $query |
98 |
body => $query |
97 |
); |
99 |
); |
98 |
}; |
100 |
}; |
99 |
if ($@) { |
101 |
if ($@) { |
100 |
die $self->process_error($@); |
102 |
die $self->process_error($@); |
101 |
} |
103 |
} |
|
|
104 |
if (ref $results->{hits}->{total} eq 'HASH') { |
105 |
$results->{hits}->{total} = $results->{hits}->{total}->{value}; |
106 |
} |
102 |
return $results; |
107 |
return $results; |
103 |
} |
108 |
} |
104 |
|
109 |
|
Lines 119-127
sub count {
Link Here
|
119 |
# and just return number of hits |
124 |
# and just return number of hits |
120 |
my $result = $elasticsearch->search( |
125 |
my $result = $elasticsearch->search( |
121 |
index => $self->index_name, |
126 |
index => $self->index_name, |
|
|
127 |
track_total_hits => JSON::true, |
122 |
body => $query |
128 |
body => $query |
123 |
); |
129 |
); |
124 |
|
130 |
|
|
|
131 |
if (ref $result->{hits}->{total} eq 'HASH') { |
132 |
return $result->{hits}->{total}->{value}; |
133 |
} |
125 |
return $result->{hits}->{total}; |
134 |
return $result->{hits}->{total}; |
126 |
} |
135 |
} |
127 |
|
136 |
|