This pull request fixes the issue where calling limit with count returns unexpected results in the CrashEvent class. The issue was caused by the size parameter being deleted in the count! method. This pull request adds the default_size to the query builder and fixes the deletion of size in the count! method.
Here's what's happening:
CrashEvent.limit(2).count has no query conditions.
We remove size before calling the elasticsearch count API endpoint.
The count API endpoint uses match_all: {} if there are no query conditions.
This pull request fixes the issue where calling
limit
withcount
returns unexpected results in the CrashEvent class. The issue was caused by thesize
parameter being deleted in thecount!
method. This pull request adds thedefault_size
to the query builder and fixes the deletion ofsize
in thecount!
method.Here's what's happening:
CrashEvent.limit(2).count
has no query conditions.size
before calling the elasticsearch count API endpoint.match_all: {}
if there are no query conditions.When we provide a query without limit
CrashEvent.where(operator: "American Airlines").count
When we provide a query with a limit
CrashEvent.where(operator: "American Airlines").limit(2).count
:size
because it's a count requestSolution
default_size
to relation@values[:default_size]
search_options
are built inQueryBuilder
count?
isfalse
size
to the user providedvalues[:size]
ORdefault_size
count?
istrue
size
to nil preventing it from being added tosearch_options
size
is set andcount
is called we returnresults.count
instead ofcount!
(which calls the Count API endpoint)Fixes #54