typesense / typesense-js

JavaScript / TypeScript client for Typesense
https://typesense.org/docs/api
Apache License 2.0
393 stars 74 forks source link

Error Updating by query with npm package & Typesense Cloud: RequestMalformed: Request failed with HTTP code 400 | Server said: For update, the `id` key must be provided. #176

Closed sgm55 closed 10 months ago

sgm55 commented 10 months ago

Description

I'm trying to update documents in a collection by using a "filter_by" query. Following the documentation, I get an error: RequestMalformed: Request failed with HTTP code 400 | Server said: For update, the id key must be provided.

Steps to reproduce

Using npm package version 1.7.1 & Typesense Cloud (v0.25.1).:

let document = { 'tag': 'large' }

client.collections('companies').documents().update(document, {"filter_by": "employee:=Chris"})

Expected Behavior

A successful request that edits the tag to "large" on all documents with the field "employee"="Chris"

Actual Behavior

Error: RequestMalformed: Request failed with HTTP code 400 | Server said: For update, the id key must be provided. at RequestMalformed.TypesenseError [as constructor] (C:\Users\A\Documents\Project\node_modules\typesense\lib\Typesense\Errors\TypesenseError.js:23:28) at new RequestMalformed (C:\Users\A\Documents\Project\node_modules\typesense\lib\Typesense\Errors\RequestMalformed.js:25:42) at ApiCall.customErrorForResponse (C:\Users\A\Documents\Project\node_modules\typesense\lib\Typesense\ApiCall.js:361:21) at C:\Users\A\Documents\Project\node_modules\typesense\lib\Typesense\ApiCall.js:220:98 at step (C:\Users\A\Documents\Project\node_modules\typesense\lib\Typesense\ApiCall.js:33:23) at Object.next (C:\Users\A\Documents\Project\node_modules\typesense\lib\Typesense\ApiCall.js:14:53) at step (C:\Users\A\Documents\Project\node_modules\typesense\lib\Typesense\ApiCall.js:18:139) at Object.next (C:\Users\A\Documents\Project\node_modules\typesense\lib\Typesense\ApiCall.js:14:53) at fulfilled (C:\Users\A\Documents\Project\node_modules\typesense\lib\Typesense\ApiCall.js:5:58) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Metadata

Typesense Version: v0.25.1 for Typesense Cloud & v1.7.1 for npm package

OS: Windows 10

jasonbosco commented 10 months ago

Could you try with v1.7.2?

sgm55 commented 10 months ago

It works now, thanks so much for the prompt response!