Skip to content

Kaminari pagination: no implicit conversion of Integer into Hash #876

@skukx

Description

@skukx

Gem: elasticsearch-model version 6.0
Cluster: Elasticsearch 7.0

The kaminari pagination is causing an error when calling next_page

resp = Model.__elasticsearch__.search query: { match_all: {} }
resp.page(1).per(2).next_page
#=> TypeError: no implicit conversion of Integer into Hash

resp.total_count
#=> #<Elasticsearch::Model::HashWrapper relation="gte" value=10000> 

Trace:

vendor/bundle/ruby/2.4.0/gems/kaminari-core-1.1.1/lib/kaminari/models/page_scope_methods.rb:36:in `<'
vendor/bundle/ruby/2.4.0/gems/kaminari-core-1.1.1/lib/kaminari/models/page_scope_methods.rb:36:in `total_pages'
vendor/bundle/ruby/2.4.0/gems/kaminari-core-1.1.1/lib/kaminari/models/page_scope_methods.rb:77:in `last_page?'
vendor/bundle/ruby/2.4.0/gems/kaminari-core-1.1.1/lib/kaminari/models/page_scope_methods.rb:62:in `next_page'

This is probably due to the breaking change in hits. See: https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.html#_literal_hits_total_literal_is_now_an_object_in_the_search_response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions