Display data from another indice

Hi guys,

I have two different indices:

  1. The first one contains a list of products with their description and id.
  2. The second one contains the list of favorites products ids of one of my customer.

Is there any way to allow my customer to search on its favorites products using product description from the first indice ?

If yes, how to do it using react instantsearch ?

Thank you

Hi @vincent

Are you saying that you’re creating one index for each of your customer ? I don’t work @Algolia but I’m not sure that’s something you should do.

It seems to me that you’re working here with two type of informations.

  • Product’s information
  • User’s information (here the favorite products)

Algolia’s power on product’s information is obvious but I don’t really understand why you want to indexes each of your customers favorites products. I can’t think of why you would want that so I’m curious.

Nevertheless, I don’t believe you can JOIN two indices so you would have to record the description product in each object of your customer favorites.

Or you could add an “customerFavorite” attributes in your Products indexes to rank products and get the ones that are favorited a lot. But that’s not what you’re asking I believe.

.

1 Like

Hi Pierre,

Thanks for your feedback. I agree with you that it may seems weird to have a specific index for favorites products of each customer. Not sure that it is a good idea to do it with algolia but I managed to create an index for each customer very easily within 20 minutes.

I am working on a poc where I will have a few customers (probably a few hundreds maximum) and a big catalog of products.
I want to give access to a portion of the catalog for each of my customers. This portion being the favorites products of the customer. (A customer can have thousands favorites products).
The customerFavorite product would not help in this case but thanks for the idea :slight_smile:

Another solution would be to duplicate product information in each customer index but it looks heavy and hard to maintain.

Hi @vincent,

You could have only one index with records following this structure:

{ 
"name": "XXX",
 // other product attributes
"favorited_by": ["user1", "user42", ...]
}

The idea is then to do two queries on the front-end. One with the index being filtered by a specific user, the other one being regular. Then you join both arrays of hits.

There’s a drawback to this method, I wouldn’t recommend having an array bigger than 1k users.

If we go back to React InstantSearch, you could have one <InstantSearch> component containing a virtual menu with the user as a defaultRefinement and a custom hit component keeping track of those hits through the state of the App.

Something like:

<App>
  <InstantSearch>
   <VirtualMenu defaultRefinement="user1"/>
   <Hits hitComponent={CustomHitComponentSavingRecords}/>
  </InstantSearch>
  <InstantSearch>
     // ... regular widgets
    <Hits hitComponent={CustomHitComponentMergingRecords}/>
  </InstantSearch>
</App>

Does it makes sense?

Hi Marie Laure,

Thanks you for the answer. Seems similar to the “customerFavorite” proposal of Pierre.

I will give it a try and come back to you :slight_smile:

Another quick question, I did not see any limitation on index on the pricing. The pricing seems to be only based on the number of records and operations.
Is there any limitation in the number of index ? Is it acceptable to have one index per customer if we have a specific catalog for each of them ?

Thank you

You’re right is the number of records that is taken into account, not the number of indices :slight_smile:

1 Like