Guides / Managing results / Refine results / Sorting results

By design, Algolia provides one ranking formula per index; therefore, when you want to provide different rankings for the same data, you need to use different indices for each ranking. These additional indices are called replicas.

You can create replicas through the API and the Dashboard.

Standard replicas

Standard replicas are an exact copy of your index with fully configurable settings. They let you to have a completely different configuration of your index, without having to manage syncing the data from the original or “primary” index.

Using the API

To create replicas, you need to use the setSettings method on your primary index. You can add more than one replica at a time if you want to provide multiple alternative sorting strategies.

1
2
3
4
5
$index->setSettings([
  'replicas' => [
    'products_price_desc'
  ]
]);

Using the dashboard

Creating a replica through the dashboard

  1. Select the Data Sources icon on your dashboard and then select your index.
  2. Click the Replicas tab.
  3. Click the Create Replica Index button.
  4. In the modal that appears, enter a name for your replica, choose standard replicas, and select Create replica.
  5. Repeat for each replica you want to add.
  6. Don’t forget to save your changes.

If the replica name refers to an existing index, it will be linked to its primary index, and its content updated.

Virtual replicas

Another way to handle different sorting strategies is via virtual replicas. Unlike standard replicas, virtual replicas don’t create a duplicate dataset from their primary index. However, you can only adjust a subset of the primary index’s settings on virtual replicas. They’re optimized for the Relevant sorting feature.

For more details on virtual replicas, please refer to the in depth page on replicas.

Virtual replicas are only available on Premium plans.

Using the API

To create virtual replicas, you need to use the setSettings method on your primary index. You can add one ore more virtual or standard replicas at a time if you want to offer multiple sorting strategies.

1
2
3
4
5
$index->setSettings([
  'replicas' => [
    'virtual(products_price_desc)'
  ]
]);

Using the dashboard

Creating a replica through the dashboard

  1. Go to your dashboard and select your index.
  2. Click the Replicas tab.
  3. Click the Create Replica Index button.
  4. In the modal that appears, enter a name for your replica, choose virtual replicas, and select Create replica.
  5. Repeat for each replica you want to add.
  6. Don’t forget to save your changes.

If the replica name refers to an existing index, it will be linked to its primary index, and its content updated.

Did you find this page helpful?