Searchkick: Am I sorting by column properly?

Created on 24 Dec 2015  路  3Comments  路  Source: ankane/searchkick

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?

question

Most helpful comment

For the code above, use:

Product.search "car", page: 0, per_page: 10, order: {created_at: {order: "desc"}}

All 3 comments

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"}}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

rajatgarg79 picture rajatgarg79  路  4Comments

mehulkar picture mehulkar  路  3Comments

tomajask picture tomajask  路  4Comments

netwire88 picture netwire88  路  3Comments

namila picture namila  路  4Comments