I am trying to delete vector based on metadata using javascript using below code but i am receiving error saying

i am trying to delete vector based on metadata using javascript using below code but i am receiving error saying - Error calling _deleteRaw: RequiredError: Required parameter requestParameters.deleteRequest was null or undefined when calling _delete.
code :
await index._delete({
filter: {
genre: { $eq: “documentary” },
year: 2019,
},
});

Hi @bharat.raj

add another { and } around the method parameter. As per documentation for JS client.

await index._delete({{
  filter: {
    genre: { $eq: "documentary" },
    year: 2019,
  },
}});

I think this should get you further :wink:

Hope this helps

Can you provide the doc from where you referred this because it is given
await index._delete({
filter: {
genre: { $eq: “documentary” },
year: 2019,
},
});
this is the right way to do

Hi @sourav.k

sure. If you are using the _delete() api, you can check the https://github.com/pinecone-io/pinecone-ts-client/blob/main/src/pinecone-generated-ts-fetch/apis/VectorOperationsApi.ts code here :slight_smile:

The code I provided solved the issue. Why?

async _delete(requestParameters: DeleteOperationRequest)

// The above method takes the requestParameters parameter that is of DeleteOperationRequest.

export interface DeleteOperationRequest {
    deleteRequest: DeleteRequest;
}

// The DeleteOperationRequest contains a deleteRequest of DeleteRequest 
export interface DeleteRequest {
  ids?: Array<string>;
  deleteAll?: boolean;
  namespace?: string;
  filter?: object;
}

So, putting it all into the method:

_delete(requestParameters: {
    deleteRequest: DeleteRequest;
})

_delete(requestParameters: {
    deleteRequest: {
    ids?: Array<string>;
    deleteAll?: boolean;
    namespace?: string;
    filter?: object;
}
});

Cleanup:
_delete({{
    ids?: Array<string>;
    deleteAll?: boolean;
    namespace?: string;
    filter?: object;
}});

Hope this helps :slight_smile: