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

[Bug] Missing type-checking for deleteMany filter argument #103

Open
2 tasks done
PrimeObjects opened this issue Sep 9, 2023 · 4 comments
Open
2 tasks done

[Bug] Missing type-checking for deleteMany filter argument #103

PrimeObjects opened this issue Sep 9, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@PrimeObjects
Copy link

PrimeObjects commented Sep 9, 2023

Is this a new bug?

  • I believe this is a new bug
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

await index.namespace(organizationId).deleteMany({
filter: {"recordId":"2bb22982-40d4-4156-a1d7-fcf11610e5c3"}
});

got error below:

{
error: PineconeBadRequestError: illegal condition for field filter, got {"recordId":"2bb22982-40d4-4156-a1d7-fcf11610e5c3"}
at mapHttpStatusError (D:\EncodeChat\encodechat-lambda\encodechat-lambda-vectordb\node_modules@pinecone-database\pinecone\src\errors\http.ts:99:14)
at (D:\EncodeChat\encodechat-lambda\encodechat-lambda-vectordb\node_modules@pinecone-database\pinecone\src\errors\handling.ts:37:32)
at step (D:\EncodeChat\encodechat-lambda\encodechat-lambda-vectordb\node_modules@pinecone-database\pinecone\dist\errors\handling.js:33:23)
at Object.next (D:\EncodeChat\encodechat-lambda\encodechat-lambda-vectordb\node_modules@pinecone-database\pinecone\dist\errors\handling.js:14:53)
at fulfilled (D:\EncodeChat\encodechat-lambda\encodechat-lambda-vectordb\node_modules@pinecone-database\pinecone\dist\errors\handling.js:5:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
}

Expected Behavior

deleteMany wsuccessfully.

Steps To Reproduce

type TPineconeMetadata = {
entityName: string;
entityType: string;
recordId: string;
ownerIds: string[];
organizationId: string;
solutionId: string;
userId: string;
text: string;
};

const metadata: TPineconeMetadata = {
entityName,
entityType,
recordId: "2bb22982-40d4-4156-a1d7-fcf11610e5c3",
ownerIds: ["2bb22982-40d4-4156-a1d7-fcf11610e5c3"],
organizationId,
solutionId,
userId,
text
};

    const pinecone = new Pinecone({
            apiKey,
            environment
        });

   const index =  pinecone.index<TPineconeMetadata>(indexName);

    await index.namespace(organizationId).upsert({
        id: "1234",
        values,
        metadata
    });
    
    //deleteMany with filter fails
    await index.namespace(organizationId).deleteMany({
            filter:  {"recordId":"2bb22982-40d4-4156-a1d7-fcf11610e5c3"}
        });
        
     ///deleteMany with array works
     await index.namespace(organizationId).deleteMany(["1234']);

Relevant log output

No response

Environment

- **OS**:
- **Language version**:
- **Pinecone client version**:

Additional Context

No response

@PrimeObjects PrimeObjects added the bug Something isn't working label Sep 9, 2023
@PrimeObjects PrimeObjects changed the title [Bug] <title> [Bug] PineconeArgumentError: The argument to upsert had type errors: argument must be array. Sep 9, 2023
@PrimeObjects PrimeObjects reopened this Sep 9, 2023
@jhamon
Copy link
Collaborator

jhamon commented Sep 10, 2023

I think your filter expression is invalid. You can see some docs about filter expressions here.

I think what you need to write is along these lines, without the top-level filter:

await index.namespace(organizationId).deleteMany({
  recordId: '2bb22982-40d4-4156-a1d7-fcf11610e5c3'
});

It's on my todo list to add better typing around these filter expressions.

@jhamon jhamon changed the title [Bug] PineconeArgumentError: The argument to upsert had type errors: argument must be array. [Bug] Missing type-checking for deleteMany filter argument Sep 11, 2023
@elliotvilhelm
Copy link

I think your filter expression is invalid. You can see some docs about filter expressions here.

I think what you need to write is along these lines, without the top-level filter:

await index.namespace(organizationId).deleteMany({
  recordId: '2bb22982-40d4-4156-a1d7-fcf11610e5c3'
});

It's on my todo list to add better typing around these filter expressions.

Thanks, that was my issue.

@jhamon
Copy link
Collaborator

jhamon commented Sep 14, 2023

Glad that unblocked you.

I have some promising work-in-progress on adding type-safety to these filter expressions, but I've paused it to prioritize showstopper bugs (e.g. typescript compilation problems) for the next incremental release. Hopefully I'll get that type safety improvement out sometime in the next couple weeks.

@jhamon jhamon added enhancement New feature or request and removed bug Something isn't working labels Sep 15, 2023
@jhamon jhamon self-assigned this Sep 15, 2023
@MontoyaAndres
Copy link

Yes, I just updated to the new 1 version, and I got this error:

illegal condition for field filter, got {"knowledgeId":{"$eq":"xxx"},"type":{"$eq":"xxx"},"workspaceId":{"$eq":"xxx"}}

And we just had to remove the filter: {xxx} object

Also, the documentation is not updated with these changes, it's still using the old methodology https://docs.pinecone.io/docs/metadata-filtering#deleting-vectors-by-metadata-filter

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants