Icon indexing white

Update strategies

Last updated 07 February 2018


After the initial import of the data, you’ll need to keep your index up-to-date with the latest additions and changes on your application or website.

You can update your records:

  • one by one in realtime or batch them
  • update a complete record or only a subset of its attributes
  • update a full index without generating inconsistencies on the search during the process

Incremental updates

Incremental updates are performed by referencing the objectID attribute of your records. By referencing this unique objectID you can add, delete, and modify an existing record’s attributes.

Adding a new record (if one doesn’t exist)

# update the record with objectID="myID1"
# the record is created if it doesn't exist
index.save_object({ :name => "Jimmy", :company => "Paint Inc." }, "myID1")

Deleting a record

# delete the record with objectID="myID1"

Updating a record

# update (or add if it doesn't exist) the attribute "firstname" of object "myID1"
index.partial_update_object({ :firstname => "Jimmie" :objectID => "myID1" })

Partial updates

In some complex use-cases, you may have several data sources having each a part of the data required to build your Algolia records.

When dealing with several sources to update a single object, you may face a versioning issue - like a laggy source trying to push an update that would be older than the one currently indexed and override it.

Algolia handles such conflicts as updates from several sources with Partial Updates. Partial updates only update a few attributes of your records without re-pushing the others.


  • You index an object
    { "name": "Benjamin", "objectID": 42 }
  • Source A send the “city” attribute with a partialUpdate
    { "city": "Paris", "objectID": 42 }
  • Once indexed, the updated object will be
    { "name": "Benjamin", "city": "Paris", "objectID": 42 }
  • Source B sends the “country” attribute with a partialUpdate
    { "country": "France", 	"objectID": 42 }
  • Once indexed, the object will be
    { "name": "Benjamin", "city": "Paris", "country": "France", "objectID": 42 }

Since the different sources are not dealing with the same attributes, they’ll never override something another source has pushed.

Atomic reindexing

In some cases, you may to want change the way your records are structured, and need to reindex all the data in an index.

In order to keep your existing service running while re-importing your data, we recommend the usage of a temporary index plus an atomical move.

# import all your data to a temporary `YourIndexName_temp` index
# [...]
# rename the tempory index to its final name
client.move_index('YourIndexName_temp', 'YourIndexName')

A move_index operation will override all the settings of the destination index, except the replicas setting.

What’s Next

Continue building your Algolia knowledge with these concepts:

If you want to get started implementing an update strategy, we have a few tutorials you might find helpful:

© Algolia - Privacy Policy