typesense / typesense-instantsearch-adapter

A JS adapter library to build rich search interfaces with Typesense and InstantSearch.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple fields for sorting

jsdmc opened this issue · comments

Hi guys.
I'm using useSortBy hook from react-instantsearch-hooks-web with typesense. Is there a way to specify multiple sortings fields for search results?
Thanks

Here's how you configure the sortBy widget: https://github.com/typesense/typesense-instantsearch-adapter#sortby

The same format of items applies for react-instantsearch too.

Here's how you configure the sortBy widget: https://github.com/typesense/typesense-instantsearch-adapter#sortby

The same format of items applies for react-instantsearch too.

Yeah, documentation is clear. But it doesn't allow specify how to sort search results by multiple fields at once. Something like that won't work.

    items: [
      { label: "Default", value: "products" },
      { label: "Popularity and price (asc)", value: "products/sort/popularity:desc,price:asc" },
      { label: "Popularity and price (desc)", value: "products/sort/popularity:desc,price:desc" },
    ],

how to sort search results by multiple fields at once

Ah I see.

That syntax should work in theory... Could you open the browser's network tab and look for a request to multi_search, and copy-paste the request body here?

how to sort search results by multiple fields at once

Ah I see.

That syntax should work in theory... Could you open the browser's network tab and look for a request to multi_search, and copy-paste the request body here?

You are right! It's working. I wasn't sure because this functionality wasn't mentioned in docs.
Thanks!