<ais-index> is a component that allows you to search in multiple Algolia indices within the same InstantSearch instance. This is useful for federated search, where you want to display results from different indices (e.g., products, articles, categories) in the same interface.
Usage
Props
The name of the Algolia index to search in.
A custom identifier for this index widget. This is useful when you want to have multiple
ais-index components with the same indexName but different search parameters.Slots
The default slot contains all search components that should query this specific index.
How It Works
Theais-index component creates a separate search context for each index. All child components within an ais-index will query that specific index.
Search State Isolation
Eachais-index maintains its own search state:
- Refinements, filters, and pagination are independent
- Only the search query is shared across all indices (if
ais-search-boxis outside index components) - Each index can have its own configuration via
ais-configure
Index Hierarchy
CSS Classes
The component renders with these CSS classes:ais-Index- Root container class
Examples
Federated Search
Multiple Indices with Different Filters
Index with Independent Refinements
Sort By with Multiple Indices
Index Composition
You can nestais-index components, though this is rarely needed:
Routing with Multiple Indices
When using routing with multiple indices, the URL state includes all index states:Related Components
- ais-instant-search - Root search component
- ais-configure - Configure index search parameters