#community-help

Handling Two Collections in One Filter Widget with React-InstantSearch

TLDR Lina wanted to handle two collections in one filter widget. Jason suggested that react-instantsearch doesn't support this and a custom widget might be needed.

Powered by Struct AI
8
7mo
Solved
Join the chat
Mar 01, 2023 (7 months ago)
Lina
Photo of md5-cdf7e647a15aa08c6347b75c2344d9fc
Lina
12:04 PM
Hi there! How are you doing? 😄
I've got a question. I need to handle 2 collections in 1 filter widget. Could you tell, is it possible?

So I have two collections with similar fields. For example:
collection_1 : id, category, status ...
collection_2 : id, category, status ...

Category may have different values. One of the possible values is General.

I need:
1. Show General option in the filter
2. When this option is selected, show General items from collection_1, but don't show General items from collection_2
Right now I came up with this solution: I'm displaying filters from collection_1, so the General option is visible there. But when I'm selecting this option, I receive hits from collection_2 with category = General as well. I need only hits with category = General from collection_1 :melting_face: Please help
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:40 PM
Are you writing custom code using the JS client or using the instant search adapter?
Lina
Photo of md5-cdf7e647a15aa08c6347b75c2344d9fc
Lina
12:42 PM
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:44 PM
Jason will be able to help with this later.
Lina
Photo of md5-cdf7e647a15aa08c6347b75c2344d9fc
Lina
12:45 PM
Thank you very much !
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:18 PM
Lina I don’t think react-instantsearch allows you to combine data from multiple collections in a single filter widget
05:18
Jason
05:18 PM
So you might have to build a custom widget
Lina
Photo of md5-cdf7e647a15aa08c6347b75c2344d9fc
Lina
05:21 PM
Ohh gotcha. This is actually what I thought. Thank you for confirming that! 🙏