React multiple-index search rankings

Hello,
I have 4 indexes within Algolia that function independently feeding their respective applications. I’d like to build a global search that can return ranked results from all the indexes. As a proof of concept, I’ll start with two but I would want the ability to scale up to 4 or 5 indexes over time.

The following code works, however in the SearchCard component i’m connecting to stateResults and then concatenating the results of allSearchResults manually. Am i missing something? Is there a way for React InstantSearch to return a collection of combined and ranked search results?

 <InstantSearch indexName='index2' searchClient={searchClient}>
      <InputBox />
      <SearchCard />
      <Index indexName='index1' />
      <Index indexName='index2' />
    </InstantSearch>

Any help or insight would be appreciated. I’m considering combining the index but that would increase complexity in the fact that we’d have to keep them in sync. Please advise when you have a moment, thank you!

Hi @jsw324,

Thanks for contacting Algolia!

If I understand your inquiry correctly, you currently have multiple indices and you would like to send a query that queries all 4 indices, and returns results combined from all 4 indices, where the results are ranked relative to each other. Is that correct?

Although you can use a single query for multiple indices (see Search multiple indices doc) they would not be “combined” in the sense you are expecting.

Each of the hits results is just for that single index (index1,…, index4) and would not be comparable to one another. Each index results are only good for records within the same index and cannot be combined and compared to each other.

As you are already doing, to “combine” results from multiple indices it would be a manual process where any ordering/ranking is determined by you and no longer powered by Algolia.

I hope this answers your question. If we misunderstood your goal, please do not hesitate to add clarifying information.

This answers my question, thank you!