Multi-index search (federated search) is a method for searching multiple data sources simultaneously. This means that when users enter a search term, Algolia will look for and display results from all these data sources. This doesn’t necessarily mean that the results from Algolia indices are combined since their contents could be quite different. Your approach may be to display the results from each separately. You could display the top-rated items from a movie index alongside the list of results from a book index. Or you could display category matches alongside the list of results from a product indexDocumentation Index
Fetch the complete documentation index at: https://algolia.com/llms.txt
Use this file to discover all available pages before exploring further.
Working example
The following demo uses an InstantSearch search box to display hits from two different indices:Open CodeSandbox
Run and edit the Multi-index search example in CodeSandbox.
Explore source code
Browse the source for the Multi-index search example on GitHub.
This code has been specifically created for Vue 2.
Some modifications may be required for it to work correctly in Vue 3.
Search multiple indices with InstantSearch
This example uses a singleais-search-box to search multiple indices. For this behavior, there are two ais-index widgets. Each of them targets a specific index: the first one is instant_search_price_desc and the second is instant_search.
Vue
Since these are two dedicated indices, you can apply different parameters and widgets to the search.
You can do it by passing different parameters to
ais-configure, or mounting different widgets in each of the ais-index components.Search multiple indices with Autocomplete
You can use the Autocomplete library in your InstantSearch app to build a dynamic multi-source search experience. For example, you may want to display Query Suggestions together with recent searches, create a multi-column layout that mixes and item previews, or even dynamically change sources based on the query.Autocomplete isn’t limited to Algolia indices: you can use static sources or fetch data from other APIs.
Category display
Algolia can help you display both category matches and results if you:- Add categories to your Query Suggestions either inline or listed below a result. For example, you might see the following in your Query Suggestions list “game of thrones in Books”
- Use multi-index search to display categories from a separate category index. This is useful if you want to display categories and Query Suggestions at the same time. Clicking such a result typically redirects to a category page. The following is a sample dataset for a product index and a category index.
Example product index
JSON
Example category index
JSON