How to separate searchable attributes to separate search boxes in Algolia?

491 views Asked by At

If I have "title" and "category" as searchable attributes in the Algolia admin, is there any way that I can have one <SearchBox /> searching only on "title" and another searching only on "category"?

At the moment, a <SearchBox /> component from react-instantsearch-dom appears to search ALL searchable attributes. I would ideally like to separate the searches.

I could not find anything for this kind of setup in the documentation: https://www.algolia.com/doc/api-reference/widgets/search-box/react/

Any help would be greatly appreciated.

1

There are 1 answers

2
JayCodist On

From Algolia docs, you could use a Configure widget lets you provide raw search parameters to the Algolia API and pass in value for the restrictSearchableAttributes property. like so:

import { Configure } from 'react-instantsearch-dom';

<Configure
  restrictSearchableAttributes={["title"]}
/>

It doesn’t render anything on screen, it only applies the provided search parameters passed in once the component mounts