community[patch]: add delete() method to AzureSearch vector store (#21127)

**Issue:**
Currently `AzureSearch` vector store does not implement `delete` method.
This PR implements it. This also makes it compatible with LangChain
indexer.

**Dependencies:**
None

**Twitter handle:**
@martintriska1

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
MacanPN
2024-05-01 01:46:18 +02:00
committed by GitHub
parent 3441a11b21
commit 0f7f448603
3 changed files with 19 additions and 2 deletions

View File

@@ -377,6 +377,22 @@ class AzureSearch(VectorStore):
else:
raise Exception(response)
def delete(self, ids: Optional[List[str]] = None, **kwargs: Any) -> bool:
"""Delete by vector ID.
Args:
ids: List of ids to delete.
Returns:
bool: True if deletion is successful,
False otherwise.
"""
if ids:
res = self.client.delete_documents([{"id": i} for i in ids])
return len(res) > 0
else:
return False
def similarity_search(
self, query: str, k: int = 4, **kwargs: Any
) -> List[Document]: