Bug 12478: fix the way counting is done

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
This commit is contained in:
Robin Sheat 2015-03-11 16:14:14 +13:00 committed by Brendan Gallagher
parent b76d61a24b
commit 45834b214c

View file

@ -85,10 +85,9 @@ sub search {
}
$self->store(
Catmandu::Store::ElasticSearch->new(
%$params,
trace_calls => 1,
%$params, trace_calls => 1,
)
);
) unless $self->store;
my $results = $self->store->bag->search( %$query, %paging );
return $results;
}
@ -107,11 +106,11 @@ sub count {
my $params = $self->get_elasticsearch_params();
$self->store(
Catmandu::Store::ElasticSearch->new( %$params, trace_calls => 1, ) );
Catmandu::Store::ElasticSearch->new( %$params, trace_calls => 1, ) )
unless $self->store;
# TODO something like this should work, but doesn't seem to just yet.
# my $count = $self->store->bag->count($query);
my $count = $self->store->bag->search(%$query)->total;
my $searcher = $self->store->bag->searcher(query => $query);
my $count = $searcher->count();
return $count;
}