How do I define related indices in algolia

I have 2 Indices (markets and traders).

Now here trader have their own indices and market have their own. And now here trader can trade at multiple markets.

Now suppose if anyone search by market name then I will show that market in search result page, but now at the same time I also want to show traders who trade at that market. So how can I do it?

I have a solution that while saving record of traders to Algolia, also I push markets in that record to which trader trader at. But in this case, what to do when market details get update on site? As at that time updating trader details will be costly operation and there will be many such traders. So any solution ?

Please help me. Thanks.

Hi,

You can indeed display multiple indices in search results. Here is a tutorial on how to do it: https://www.algolia.com/doc/tutorials/search-ui/autocomplete/how-to-display-results-from-multiple-indices-with-autocomplete-js/.

Ronan

Hi @ronan.levesque , yes this thing I know and I already have implemented, but how can I provide relations, such for example above doc link have players and teams, so now if I search with player name then in search list that player need to show and also I want to show player’s team ? So how can I achieve this ?

I can push all teams of player to player’s record, but what when team name will get updated via website.

Please help. Thanks.

You will have 2 different solutions for this:

  • You can either make use of Distinct, but this will require that you reformat your Database to reach the results you are looking for
  • Or you can use a backend search, and aggregate data on your side.

Hope that helps,

Ronan