Skip to main content
A federated search offers search results, Query Suggestions, product categories, and other content from multiple indices in a single interface. Screenshot of a search interface showing autocomplete suggestions for 'cell' with product results and categories.

Open CodeSandbox

Run and edit the Autocomplete with Federated Search example in CodeSandbox.

View code on GitHub

View the Autocomplete with Federated Search example code on GitHub.

Before you begin

This tutorial extends Build a Query Suggestions UI with Autocomplete.

Combine different data sources

With different indices for different content types, you can optimize the relevance for each type. For example, blog posts might require a different ranking strategy than products. Federated search can search multiple indices simultaneously and show the results in the same interface. You can combine data sources in four different ways: You can add multiple data sources to Autocomplete with getSources. In this tutorial, Autocomplete uses these data sources:
  • Query Suggestions from the index instant_search_demo_query_suggestions
  • Product catalog from the index instant_search
  • Hierarchical product categories from instant_search

Add Query Suggestions as first data source

Follow the steps in Adding Query Suggestions to set up autocomplete-plugin-query-suggestions.

Add search results for products as second data source

First, import getAlgoliaResults from the autocomplete-js package to get results from an Algolia index.
JavaScript
Next, use getSources and getAlgoliaResults to get matching products from the Algolia index instant_search. This example uses custom rendering with Preact components.
JavaScript

Add product categories as third data source

To add categories to the federated search, import getAlgoliaFacets from autocomplete-js.
JavaScript
Now add getAlgoliaFacets to getSources to add the product categories:
JavaScript

Next steps

Beyond this example, you can add more data sources. To make your data sources reusable and shareable, encapsulate them as plugins. For more information, see Build your own plugin. You can also add more features, such as:
  • Merchandising. Use Rules and merchandising to promote queries or items in the empty-search state or no-results state.
  • Personalization. Use Algolia’s personalization feature to enhance Query Suggestions or products.
  • Dynamic Re-ranking. Let Algolia’s Dynamic Re-ranking feature boost popular Query Suggestions or products.

See also

Last modified on July 14, 2026