Multiple Indices in iOS App

I’m using Algolia in my iOS app. I followed the Instant Search guide and am able to display results based on one index.

However, all of the code is in the AppDelegate and specifies only 1 view controller.

How do search through multiple indexes in different viewcontrollers?

Hello @phil.manning11,

Thanks for contacting us, and that’s a good feedback! You can check this Pull Request that introduces multi-indexing so that you can target your search data on different indices. This will be released in the coming week. Is this what you were looking for?

There is a way for early access if you want to play around with it. Just note that apis might change before the release. This is an example (and another one here) of an app using the new version. This is how the Podfile looks like to access the new branches that are work in progress. Let me know if you need more guidance, or if you have any feedback :slight_smile:

Also, I am a contributor to InstantSearch iOS and would love to hear about your feedback if you have anything more to say :slight_smile:


Hey Guy -

Thanks for the detailed explanation.

I’m loving algolia search so far - but I seem to be only able to implement it in the most basic of ways. I’m trying to use it for even more of my app but that’s where I run into problems. That being said I’ve found the documentation to be extreeeemely helpful.

This seems to be multi-indexing on one VC. Is mult-indexing on separate view controllers much easier though? I wasn’t sure if I just had to call the AppDelegate code on each specific VC.

Hello again,

I’m happy that you’re enjoying Algolia so far and understand your concerns for flexibility. This is definitely our focus with the release of multi indexing that is coming up.

You can actually have multi-indexes on seperate view controllers with no problems! You don’t have to call the AppDelegate code on each sepcific VC, only do it once, and then use the singleton InstantSearch.shared in order to call any apis of InstantSearch.

The second example that I linked in the my previous reply does show how you can have different indices in different VCs. The documentation around that (which I am currently writing) will make things more clear :slight_smile: (coming this week)

Your feedback is actually very useful and that will help me write better docs! Feel free to share more of them!

Great thanks for the info! I just peeked around at the pull request to see how to implement it. I’ll try it out today!

1 Like