Snapshot copy-and-swap vs in-place settings updates for searchable attribute changes
0 reputation · 05 Apr 2022, 14:35 UTC
0 reputation · 05 Apr 2022, 14:35 UTC
Assuming the current Algolia API, we need to change searchable attributes on a small index that accepts continuous writes without introducing downtime or stale results. The documented options appear to be a snapshot copy-and-swap via copyIndex plus alias repointing, or an in-place settings update on the live index.
The copy-and-swap path avoids applying new relevance rules immediately, but records written to the source during the copy are missing from the destination, and API keys tied to the original index name do not follow an alias. The in-place path keeps records current, but the new settings take effect at once and may reference attributes that are not yet populated, producing transient errors or degraded relevance.
Which trade-off is safer for a small writable application: a reconciliation window after an atomic alias swap, or a brief period of degraded queries during an immediate settings update? Are there documented copyIndex scope options or write-handling patterns that reduce risk on either path without quiescing writes?
31775 reputation · 05 Apr 2022, 19:31 UTC
For a small Algolia index that accepts continuous writes, an in-place settings update is usually the safer default when the new searchable attributes are already present on most records. It avoids a reconciliation window and keeps API keys valid. Choose copy-and-swap only if applying the new settings immediately would produce unacceptable degraded relevance because the target attributes are missing or sparse, and you can tolerate a brief post-swap reconciliation.
Confirmed by documented behavior: copyIndex produces a point-in-time snapshot; records written to the source during the copy are absent from the destination. An in-place settings update applies the new searchableAttributes immediately.
Likely, but verify for your dataset: On a small index the copy duration is short (seconds to a couple of minutes). If your write volume is low, the number of missed records may be small enough to reconcile with a simple replay. If writes are frequent, the reconciliation window grows and the risk of stale results increases.
searchableAttributes. If most records already contain the fields, use in-place update.copyIndex on a test index of similar size and record elapsed time. Compare against your write rate to estimate the gap.Use a scoped test index before touching production. For example, to measure copy time:
time curl -X POST -H "X-Algolia-API-Key: $ADMIN_KEY" -H "X-Algolia-Application-Id: $APP_ID" "https://$APP_ID.algolia.net/1/indexes/source_index/operation" -d '{"operation":"copy","destination":"test_destination"}'
After the operation completes, compare a known recent record set between source and destination. This assumes Algolia's current REST API v1; confirm endpoint availability for your plan.
What is your typical write rate per minute, and how long does copyIndex take for an index of this size? If the copy finishes in seconds and writes are rare, the snapshot swap is low-risk. If writes are continuous and the copy takes minutes, in-place update is likely safer unless you already have a replay mechanism.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.