InstantSearchJS multiindex faceting

Hi!

Is there a way to do faceting when I have multiple indices and using instantsearchjs javascript library?

For instance I have this data structure

Shows Index

[{
   objectID: 1,
   showName: "Ang Probinsyano"
   blurb: "A young voyeur (DANIEL FERNANDO) makes a habit of watching the couple living downstairs make love."
},
{
   objectID: 2,
   showName: "A Love to Last",
   blurb: "Closely studying the sex routine of the security guard (ORESTES OJEDA) and his wife (ANA MARIE GUTIERREZ), the voyeur takes over the husband’s place one night."
}]

Celebrities Index
[{
   showAppearances: ["Ang Probinsyano"],
   celebrityName: "Coco Martin",
   objectID: 1
},
{
   showAppearances: ["Ang Probinsyano", "A Love to Last"],
   celebrityName: "Maja Salvador"
   objectID: 2
},
{
   showAppearances: ["A Love to Last"],
   celebrityName: "Bea Alonzo"
   objectID: 3
}]

Given the indices above, is there a way to do faceting for celebrity? We’re using the same logic as below given by @vvo for querying for multi-index using instantsearchjs library. https://jsfiddle.net/j9nwpz34/

Thanks!

Hi @markdaniel_tamayo,

Did you try adding faceting to your multi index logic and something didn’t work as expected? If that’s the case can you give us a live example with the issue?

You should be able to add any widgets to each of the instantsearch. Here’s a jsfiddle showing two different refinement list for the two targeted indices: https://jsfiddle.net/mthuret/j9nwpz34/18/

Hi @marielaure.thuret

Our search is very similar to your movies demo, please refer to https://www.algolia.com/product

However, we have 2 index for this, 1 for the shows, which already includes the faceting of genre and another index for celebrities.

The reason we use 2 indices is to be flexible for the requirement to update. For instance another show has been added to one actor, we’ll just included it in the showAppearances array. Also should there be update in the celebrityDescription field (was not included in the sample index above), we’ll only be updating a single index rather than query from all the index records where the celebrity appears and update all of it.

First, given this scenario, do you think it will be best for us to do this kind of implementation? If will it be possible to do the same faceting as your sample movies index provided that celebrities/actors index is separated?

Thanks!

If you have an array of actors within your shows records, did you find this hard to update when new actors are added to them? Can you detail what it is maybe there’s a solution I can provide here.

If you use two indices and want to display shows that are filtered by celebrities, then you’ll need to filter on the celebrities index, and then when the hits gets back, you’ll need to find the shows based on them. Is that correct?