Skip to main content

How do I implement a default_scope order when I'm using searchkick?

General • Asked by Jeramae Bohol

Before I implemented searchkick/elasticsearch on my rails app, the default_scope -> { order(created_at: :desc) } works. But after implementing searchkick/elasticsearch, it doesn't work anymore.


Since Searchkick is a whole separate process, it won't know about your Rails stuff. What I would say is if you write a helper method or class you can have it apply that scope to the options you pass in so that it always searches the same default scope.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.