Instantsearch.js: Guide: displaying hits from different indices

Created on 8 Jun 2016  路  17Comments  路  Source: algolia/instantsearch.js

We need a guide showing how to display hits from different indices using a single searchbox.

Guide

Most helpful comment

@matthewv789 Just did an example right here: https://jsfiddle.net/j9nwpz34/, let me know how it goes

2016-06-28-140320_757x448_scrot

All 17 comments

Is this issue suggesting that it's already possible to reference multiple indexes with a single search box (or to wire separate search boxes together to work in sync with each other), and we just need to know what code to use to wire it up? The previously-mentioned issue suggested it may not have been possible currently, so I'm confused if it is or isn't. If so, can anyone point out how that would be done? In brief terms, not necessarily well-written documentation at this point. Wiring two search boxes together (and hiding one) would be a fine solution.

@matthewv789 Just did an example right here: https://jsfiddle.net/j9nwpz34/, let me know how it goes

2016-06-28-140320_757x448_scrot

THANK YOU Vincent! So easy, you're right, just a matter of a little documentation (or an example). And now an example exists. :) All it takes it that "otherIndex.helper.setQuery(query); otherIndex.helper.search();" You just made my day (or week really).

Could we also try to have a way to leverage multiple queries, to reduce the number of API calls ?

Could we also try to have a way to leverage multiple queries, to reduce the number of API calls ?

The number of API calls will stay the same right? Only the number of requests made by the browser will be lower. We could do that but only if we prove it's faster somehow which is not something obvious.

Is there a way to add faceting when using multiple indices with instantsearch?

Same question as @mtbnut
@vvo how can we use a single refinementlist (and any other facet) to target two indices?
Thanks in advance

Thanks to you both for those questions, right now I have no specific answer but multiple indices and faceting is something we want to address in our various InstantSearch libraries.

@tevatahiti @mtbnut Can you give us more details about your usecase on our discourse forum? We want to understand what you want to achieve within your data/usecase context to better serve you.

Ask your question here with some more details and we will handle it: https://discourse.algolia.com/

Does the example code posted by @vvo still work with the current version of InstantSearch.js? I'm getting a "Cannot read property 'helper' of undefined" error when I'm trying to access the helper property of "products" on line 7 of the JSFiddle (https://jsfiddle.net/j9nwpz34/).

@philiplindberg I don't get that error, was that link your version or ours?

screen shot 2018-08-01 at 11 15 49

I was referring to my local instance of InstantSearch (v2.9.0). The JSFiddle that I linked to works fine.

It's when I try to incorporate the code into my own project that I'm running into issues, specifically when trying to access the "helper" property of the second InstantSearch instance within the searchFunction of the first InstantSearch instance.

could you open a new issue with a fiddle where that error is thrown please @philiplindberg ? thanks!

It was actually an issue with my implementation - thanks for the help though, @Haroenv!

It was actually an issue with my implementation - thanks for the help though, @Haroenv!

Sorry @philiplindberg but I get that error too, what was the issue ??

@FaberPanda, please give a link to a code sandbox or fiddle where you get an error. https://jsfiddle.net/j9nwpz34/ works fine for me

@FaberPanda, please give a link to a code sandbox or fiddle where you get an error. https://jsfiddle.net/j9nwpz34/ works fine for me

Hi @Haroenv , there it is. The error happens on line 137

https://jsfiddle.net/9uak3vtj/2/~~

Found it, just had to put the "start" calls in the right order...

aha perfect, I was just about to look into it deeper when I saw you edited your post @FaberPanda

Was this page helpful?
0 / 5 - 0 ratings