Search code examples
azureazure-cognitive-search

Updating documents in Azure search index one by one or in batch?


I need to update around 10 documents to Azure search index every five minutes.

So which is a better option, updating document one by one by calling async API 10 times, or calling the API only once with all 10 documents.

Note: the number of documents can be more or less (5, 20, 30...) depending on the request.


Solution

  • This would depend on multiple factors , what's the size of the every document and type of update needed. as every https request can have a size limit and if size is big performing multiple update could be faster else single request update.

    Here, you can find fields which are allowed to be update without index rebuild -

    https://learn.microsoft.com/en-us/rest/api/searchservice/update-index

    Once above is established, application should check for concurrency if on the fly is performed and since your requirement is for every 5 minutes, concurrency check would be critical in case multiple user access the same index-

    https://learn.microsoft.com/en-us/azure/search/search-howto-concurrency