I am attempting to support searching and sorting by column. I understand I can use the fields setting to set an array of columns to search against. But, I didn't see any example of sorting other than a reference to the fact that it is supported. Looking at the Elasticsearch docs, I would think that something like this would be supported:
Product.search "car", page: 0, per_page: 10, sort: { created_at: { order: "desc" } }
I wasn't able to get the above to work. The pagination values work, but the sorting isn't taking effect.
Should it be different?
You'll need to use order instead of sort. Unfortunately, Searchkick doesn't throw an error for unrecognized options, but I'd gladly accept a pull request for it.
Can you provide an example of the correct structure from what I posted above? I can try to create a pull request, but want to confirm the kind of call that should be supported. Also, will be helpful for tests.
For the code above, use:
Product.search "car", page: 0, per_page: 10, order: {created_at: {order: "desc"}}
Most helpful comment
For the code above, use: