Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AzureSearch delete method does not use the variable FIELDS_ID therefore it does not override the value #22314

Open
5 tasks done
SebanDan opened this issue May 30, 2024 · 0 comments
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@SebanDan
Copy link
Contributor

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

The following code from AzureSearch class

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

Do not use the FIELDS_ID variable defined at the top of the script therefore it doesn't allow complete override of the key field in Azure AI Search.

Simply replacing by:

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([{FIELDS_ID: i} for i in ids])
            return len(res) > 0
        else:
            return False

Will do the trick.

Error Message and Stack Trace (if applicable)

No response

Description

I'm using langchain to interact with Azure AISearch , as I want to remove documents based on their id (the key field in AISearch) I would like Langchain to offer override capabilities for this field

System Info

No specific info

@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label May 30, 2024
ccurme pushed a commit that referenced this issue Jun 3, 2024
**Description**

Fix AzureSearch delete documents method by using FIELDS_ID variable
instead of the hard coded "id" value

**Issue:** 

This is linked to this issue:
#22314

Co-authored-by: dseban <dan.seban@neoxia.com>
hinthornw pushed a commit that referenced this issue Jun 20, 2024
**Description**

Fix AzureSearch delete documents method by using FIELDS_ID variable
instead of the hard coded "id" value

**Issue:** 

This is linked to this issue:
#22314

Co-authored-by: dseban <dan.seban@neoxia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
1 participant