Lines 49-55
use Koha::SearchEngine::QueryBuilder;
Link Here
|
49 |
use Koha::SearchEngine::Search; |
49 |
use Koha::SearchEngine::Search; |
50 |
use Koha::Exceptions::Elasticsearch; |
50 |
use Koha::Exceptions::Elasticsearch; |
51 |
use MARC::Record; |
51 |
use MARC::Record; |
52 |
use Catmandu::Store::ElasticSearch; |
|
|
53 |
use MARC::File::XML; |
52 |
use MARC::File::XML; |
54 |
use Data::Dumper; #TODO remove |
53 |
use Data::Dumper; #TODO remove |
55 |
use Carp qw(cluck); |
54 |
use Carp qw(cluck); |
Lines 117-131
faster than pulling all the data in, usually.
Link Here
|
117 |
|
116 |
|
118 |
sub count { |
117 |
sub count { |
119 |
my ( $self, $query ) = @_; |
118 |
my ( $self, $query ) = @_; |
|
|
119 |
my $elasticsearch = $self->get_elasticsearch(); |
120 |
my $conf = $self->get_elasticsearch_params(); |
120 |
|
121 |
|
121 |
my $params = $self->get_elasticsearch_params(); |
122 |
# TODO: Probably possible to exclude results |
122 |
$self->store( |
123 |
# and just return number of hits |
123 |
Catmandu::Store::ElasticSearch->new( %$params, trace_calls => 0, ) ) |
124 |
my $result = $elasticsearch->search( |
124 |
unless $self->store; |
125 |
index => $conf->{index_name}, |
|
|
126 |
body => $query |
127 |
); |
125 |
|
128 |
|
126 |
my $search = $self->store->bag->search( %$query); |
129 |
return $result->{hits}->{total}; |
127 |
my $count = $search->total() || 0; |
|
|
128 |
return $count; |
129 |
} |
130 |
} |
130 |
|
131 |
|
131 |
=head2 search_compat |
132 |
=head2 search_compat |
Lines 407-424
the default value for this setting in case it is not set)
Link Here
|
407 |
sub max_result_window { |
408 |
sub max_result_window { |
408 |
my ($self) = @_; |
409 |
my ($self) = @_; |
409 |
|
410 |
|
410 |
$self->store( |
411 |
my $elasticsearch = $self->get_elasticsearch(); |
411 |
Catmandu::Store::ElasticSearch->new(%{ $self->get_elasticsearch_params }) |
412 |
my $conf = $self->get_elasticsearch_params(); |
412 |
) unless $self->store; |
|
|
413 |
|
413 |
|
414 |
my $index_name = $self->store->index_name; |
414 |
my $response = $elasticsearch->indices->get_settings( |
415 |
my $settings = $self->store->es->indices->get_settings( |
415 |
index => $conf->{index_name}, |
416 |
index => $index_name, |
416 |
flat_settings => 'true', |
417 |
params => { include_defaults => 'true', flat_settings => 'true' }, |
417 |
include_defaults => 'true' |
418 |
); |
418 |
); |
419 |
|
419 |
|
420 |
my $max_result_window = $settings->{$index_name}->{settings}->{'index.max_result_window'}; |
420 |
my $max_result_window = $response->{$conf->{index_name}}->{settings}->{'index.max_result_window'}; |
421 |
$max_result_window //= $settings->{$index_name}->{defaults}->{'index.max_result_window'}; |
421 |
$max_result_window //= $response->{$conf->{index_name}}->{defaults}->{'index.max_result_window'}; |
422 |
|
422 |
|
423 |
return $max_result_window; |
423 |
return $max_result_window; |
424 |
} |
424 |
} |