Understanding replicas
What replicas are and how to handle them.
Algolia has one ranking formula per index. Every index has a unique sorting strategy but you can’t change it at query time. This is because pre-sorting during indexing instead of at query time leads to a considerable performance boost.
The key use of replica indices is they let you provide different rankings for the same data.
Algolia lets you automatically replicate the content of one index (the primary) onto other indices (standard and virtual replicas) and synchronize content changes.
Standard and virtual replicas
Standard and virtual have similarities and differences that affect which one you should use but, in short, if you need:
- Exhaustive sorting, pick standard replicas. Shows everything that matches, strictly sorted by a chosen attribute. For example, on a news site sort articles by publication date.
- Relevant sorting, pick virtual replicas. It prioritizes relevant results while still incorporating the sorting preference for the chosen attribute. For example, searching for “chromebook” on an electronics site should show laptops first, not Chromebook accessories.
Similarities
- You can search a replica index as you would any primary index.
- You can’t add, update, or delete records in replica indices.
- Both replica types synchronize with any updates made to records in the primary index. Every time you add, update, or delete records in your primary index, your replica is automatically modified. You can’t alter this automatic data synchronization.
Index settings
Replicas start with the same settings as their primary index, but you can change them. For example, to sort:
- By price
- In ascending order
- In descending order
- By most viewed.
Algolia applies one sorting strategy to each index.
You can only sort by attributes with boolean or numerical values. If you want to sort by dates, convert the dates to Unix timestamps.
To keep replica settings in sync with your primary index, set the primary index’s forwardToReplicas
to true
.
Differences
Standard replicas | Virtual replicas | |
---|---|---|
Availability | Available on all pricing plans | Only available on the Build and Premium pricing plans |
Records | Increases the number of records since it’s a copy of its primary index | Doesn’t increase the number of records since it’s just a view of its primary index. It does slightly increase the primary index’s size (but by less than 10 MB per million records) |
Usage | Optimized for exhaustive sorting | Optimized for relevant sorting |
Number of replicas per index | Unlimited | 20 |
Supported index settings | All | A subset |
Synonyms | Supports all synonym types | Supports most synonym types, except placeholders |
Manage replicas
Create replicas
Create replicas with the dashboard or the API and then change the replica’s sorting.
Delete or unlink a replica
You can’t edit the contents of a replica index. If you want to edit or delete the replica, you first have to unlink it from its primary index, which turns it into a regular index. Once unlinked, changes to the primary index no longer propagate to the replica index.
Detaching a virtual replica creates an empty index.
Virtual replica parameters
Virtual replicas support a subset of the index settings. You can find the supported and unsupported parameters in the following lists.
Supported parameters
advancedSyntax
advancedSyntaxFeatures
alternativesAsExact
allowTyposOnNumericTokens
aroundPrecision
attributeCriteriaComputedByMinProximity
attributesToHighlight
attributesToSnippet
attributesToRetrieve
distinct
enablePersonalization
enableRules
exactOnSingleWordQuery
highlightPostTag
highlightPreTag
hitsPerPage
ignorePlurals
maxFacetHits
maxValuesPerFacet
minProximity
minWordSizefor1Typo
minWordSizefor2Typos
paginationLimitedTo
queryLanguages
queryType
removeStopWords
replaceSynonymsInHighlight
responseFields
restrictHighlightAndSnippetArrays
snippetEllipsisText
sortFacetValuesBy
typoTolerance
unretrievableAttributes
Unsupported parameters
You can’t change the following parameters for virtual indices. Instead, change them on the corresponding primary index or create a standard replica.
attributeForDistinct
attributesForFaceting
camelCaseAttributes
customNormalization
decompoundedAttributes
disableExactOnAttributes
disablePrefixOnAttributes
disableTypoToleranceOnAttributes
disableTypoToleranceOnWords
indexLanguages
keepDiacriticsOnCharacters
numericAttributesForFiltering
optionalWords
searchableAttributes
userData
Was this page helpful?