View | Details | Raw Unified | Return to bug 12478
Collapse All | Expand All

(-)a/Koha/SearchEngine/Elasticsearch/Search.pm (-3 / +3 lines)
Lines 43-49 use C4::Context; Link Here
43
use Koha::ItemTypes;
43
use Koha::ItemTypes;
44
use Koha::AuthorisedValues;
44
use Koha::AuthorisedValues;
45
use Koha::SearchEngine::QueryBuilder;
45
use Koha::SearchEngine::QueryBuilder;
46
46
use MARC::Record;
47
use Catmandu::Store::ElasticSearch;
47
use Catmandu::Store::ElasticSearch;
48
48
49
use Data::Dumper; #TODO remove
49
use Data::Dumper; #TODO remove
Lines 120-127 sub count { Link Here
120
        Catmandu::Store::ElasticSearch->new( %$params, trace_calls => 0, ) )
120
        Catmandu::Store::ElasticSearch->new( %$params, trace_calls => 0, ) )
121
      unless $self->store;
121
      unless $self->store;
122
122
123
    my $searcher = $self->store->bag->searcher(query => $query);
123
    my $search = $self->store->bag->search( %$query);
124
    my $count = $searcher->count();
124
    my $count = $search->total() || 0;
125
    return $count;
125
    return $count;
126
}
126
}
127
127
(-)a/t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t (-2 / +10 lines)
Lines 17-23 Link Here
17
use strict;
17
use strict;
18
use warnings;
18
use warnings;
19
19
20
use Test::More tests => 5;    # last test to print
20
use Test::More tests => 10;    # last test to print
21
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
21
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
22
22
23
my $builder = Koha::SearchEngine::Elasticsearch::QueryBuilder->new( { index => 'mydb' } );
23
my $builder = Koha::SearchEngine::Elasticsearch::QueryBuilder->new( { index => 'mydb' } );
Lines 37-39 ok( my $query = $builder->build_query('easy'), 'Build a search query'); Link Here
37
37
38
ok( my $results = $searcher->search( $query) , 'Do a search ' );
38
ok( my $results = $searcher->search( $query) , 'Do a search ' );
39
39
40
- 
40
ok( my $marc = $searcher->json2marc( $results->first ), 'Convert JSON to MARC');
41
42
is (my $count = $searcher->count( $query ), 0 , 'Get a count of the results, without returning results ');
43
44
ok ($results = $searcher->search_compat( $query ), 'Test search_compat' );
45
46
ok (($results,$count) = $searcher->search_auth_compat ( $query ), 'Test search_auth_compat' );
47
48
is ( $count = $searcher->count_auth_use($searcher,1), 0, 'Testing count_auth_use');

Return to bug 12478