Set a default value for sortBy widget with instantsearch.js

Good day everyone,

I have a hopefully straightforward question. We have a sortBy widget in use and it has a “Newest” value, a “By price low to high” and “By price high to low”. Everything with that part works just fine, it’s ordering properly with the replica indices

What we’re wondering is if it’s possible to set one of them to be the default ordering. Right now it’s the default relevance ordering. I noticed the defaultRefinement attribute from the React component, but that doesn’t seem to be working with instantsearch.js version.

Any leads would be awesome.

Any thoughts on this one? :smiley:

@michael6 looking at the source code, there doesn’t seem to be a way to specify a default sort.

However, using the connector for sortBy would allow a Developer to influence which option is selected. Since this would be the default sort, you would also want to stop the original (non-sorted) request so you’ll want to set up a query proxy as described here.

Thanks @michael.king