vue-instantsearch icon indicating copy to clipboard operation
vue-instantsearch copied to clipboard

Get results from all indexes with multi index search

Open victorgambert opened this issue 5 years ago • 3 comments

Feature ⚡️

What is your use case for such a feature?

I use multi index search with one main index and two secondary indexes. I used the implementation proposed in the documentation here : https://www.algolia.com/doc/guides/building-search-ui/ui-and-ux-patterns/multi-index-search/vue/#hits-from-multiple-indices

When I want to detect if a query has results I tried to catched hits with the ais-state-results component but it only react with main index results. If I have two hits in each secondary indexes and zero hits in the main index, ais-state-results will return zero hits.

Or I want to display a message when a query has no results for all indexes. I there a native solution for that problem ?

What is your proposal

Use an array of indexes in the ais-instant-search props "index-name" for multi index search and aggregate all results in the ais-hits

or

React with all ais-index and ais-state-results and not only with the main index

What is the version you are using?

vue-instantsearch v3.4.3

victorgambert avatar Mar 16 '21 15:03 victorgambert

That's a good point, ais-state-results should get access to the full results too (called scoped results). A solution is to use a custom widget like this: https://codesandbox.io/s/sad-currying-8ditm?file=/src/App.vue

Haroenv avatar Mar 16 '21 16:03 Haroenv

Thank you very much for your quick answer 🙏 I tried your solution and it works well !

I just have a vue warning when I use it with Nuxt :

[Vue warn]: Multiple root nodes returned from render function. Render function should return a single root node.

victorgambert avatar Mar 18 '21 10:03 victorgambert

Could you make a reproduction on codesandbox? this is likely related to a change you made from my example @victorgambert :)

Haroenv avatar Mar 18 '21 11:03 Haroenv

This is an old issue, so I'll assume that it has been fixed in the mean time. If you have more issues, please open a new issue and give a reproduction. Thanks!

Haroenv avatar Dec 21 '22 16:12 Haroenv