Azure / Azure/azure-search-vector-samples

Python azure-search-backup-and-restore: appending the list failed_keys appears to fail

Open
#261 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
910
Forks
377
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Open demo-python/code/index-backup-restore/azure-search-backup-and-restore.ipynb and inspect the cells around the linked lines 171 and 173, comparing the page and item shapes with the referenced IndexingResult documentation. Reproduce the failed-key path and update the notebook so backup and restore completes without the reported AttributeErrors.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, jupyter-notebook, python
Domain
backend, cloud, search
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.