-
Hi there I have the following code that you can search on courses and see which universities have that course. I get hits based on the name from 2 indexes courses and universities. Works fine but what I want to do is only show only 1 set of hits not 2 seperate hits like now. So the results would be university and course information in one hit result set. How would I do this, I have as id that links the two indexes together. const searchClient = algoliasearch(
'app id',
'key'
);
const search = instantsearch({
indexName: 'courses',
searchClient,
});
search.addWidgets([
instantsearch.widgets.configure({
hitsPerPage: 8,
}),
instantsearch.widgets.searchBox({
container: '#searchbox',
}),
instantsearch.widgets.hits({
container: '#hits-instant-search',
templates: {
item:
'{{#helpers.highlight}}{ "attribute": "ss_title_field" }{{/helpers.highlight}}',
},
}),
instantsearch.widgets
.index({ indexName: 'universities' })
.addWidgets([
instantsearch.widgets.configure({
hitsPerPage: 16,
}),
instantsearch.widgets.hits({
container: '#hits-instant-search-price-desc',
templates: {
item:
'{{#helpers.highlight}}{ "attribute": "spell" }{{/helpers.highlight}}',
},
}),
]),
]);
search.start(); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If you want a single set of results, the data needs to be in a single index; otherwise the ranking strategy and pagination can not happen properly. |
Beta Was this translation helpful? Give feedback.
If you want a single set of results, the data needs to be in a single index; otherwise the ranking strategy and pagination can not happen properly.