Skip to main content
This page documents an earlier version of the API client. For the latest version, see Replace all records.
Required ACL: addObject This method lets you replace all records in your index without downtime. It performs these operations:
  1. Copy settings, synonyms, and rules from your original index to a temporary index.
  2. Add your new records to the temporary index.
  3. Replace your original index with the temporary index.
  • Use the safe parameter to ensure that these (asynchronous) operations are performed in sequence.
  • If there’s an error duing one of these steps, the temporary index won’t be deleted.
  • This operation is rate-limited.
  • This method creates a temporary index: your record count is temporarily doubled. Algolia doesn’t count the three days with the highest number of records towards your monthly usage.
  • If you’re on a legacy plan (before July 2020), this method counts two operations towards your usage (in addition to the number of records): copySettings and moveIndex.
  • The API key you use for this operation must have access to the index YourIndex and the temporary index YourIndex_tmp.

Examples

Replace all records

var client = new SearchClient("YourApplicationID", "YourWriteAPIKey");
var index = client.InitIndex("YourIndexName");

var objects = /* Fetch your objects */;
index.ReplaceAllObjects(objects);

Replace all records and wait for operations

var client = new SearchClient("YourApplicationID", "YourWriteAPIKey");
var index = client.InitIndex("YourIndexName");

var objects = /* Fetch your objects */;
index.ReplaceAllObjects(objects, true);

Parameters

objects
list
required
List of records.Python: Use an iterator instead of a list to prevent memory issues, especially if you want to replace many records.
requestOptions
object
A mapping of request options to send along with the query.
safe
boolean
default:false
If true, wait after each step before continuing.
I