typesense / typesense-instantsearch-adapter

A JS adapter library to build rich search interfaces with Typesense and InstantSearch.js
MIT License
402 stars 63 forks source link

allow to use custom sort_by parameter in the request #164

Open foodelix-admin opened 1 year ago

foodelix-admin commented 1 year ago

Change Summary

when using useConfigure hook from react-instantsearch-hooks-web it is now possible to put sort_by parameter under the additionalSearchParameters object

useConfigure({ //...other configurations additionalSearchParameters: { sort_by: your sort rules, // for example you can use it like this // sort_by: location(${activeSearchRegion?.lat}, ${activeSearchRegion?.lon}):asc, }, })

PR Checklist

jasonbosco commented 1 year ago

This should already work without the changes in this PR.

In this line notice how the existing code has snakeCasedAdditionalSearchParameters.sort_by. That just uses params.additionalSearchParameters.sort_by after accounting for collection specific parameters, case sensitivity, etc.