azure-search-vector-samples
azure-search-vector-samples copied to clipboard
Python azure-search-backup-and-restore: appending the list failed_keys appears to fail
I'm not sure this is an artifact of my use of the notebook functions, or some type mismatch in the notebook implementation.
You can try to trigger the problem I'm describing by negating this condition
https://github.com/Azure/azure-search-vector-samples/blob/fcfd950b2426de00ae5b53d093d4449823ed05cc/demo-python/code/index-backup-restore/azure-search-backup-and-restore.ipynb?short_path=4a07276#L171
As a consequence, the azure-search-backup-and-restore notebook appears to fail on appending the list failed_keys, since page
appears to be a list of dicts
https://github.com/Azure/azure-search-vector-samples/blob/fcfd950b2426de00ae5b53d093d4449823ed05cc/demo-python/code/index-backup-restore/azure-search-backup-and-restore.ipynb?short_path=4a07276#L173
failed_keys.append(page[result.index_of(item)].id)
^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'index_of'
Trying to use the list.index fails on dict.id attribute access
failed_keys.append(page[result.index(item)].id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'id'
The following failed_keys.append(page[result.index(item)]["id"])
allows to advance further, but then fails at
print(f"Document upload error: {item.error.message}")
^^^^^^^^^^
AttributeError: 'IndexingResult' object has no attribute 'error'
which should probably be print(f"Document upload error: {item.error_message}")
, since item
appears to be an instance of https://learn.microsoft.com/en-us/python/api/azure-search-documents/azure.search.documents.models.indexingresult
An extra question: are there any news about Azure AI Search getting a functionality of automatic index snapshots/backups and restores? The lack of this may create a friction in adoption of Azure AI search in enterprise setups.