typesense-php icon indicating copy to clipboard operation
typesense-php copied to clipboard

Update by query is asking for an id

Open tykobradyer opened this issue 2 years ago • 1 comments

Description

I am trying to implement an update-by-query operation similar to the official docs. But I get an error saying:

For update, the id key must be provided.

Steps to reproduce

Code is almost identical to the official docs sample:

$document = ['field' => 'new_value'];
$filter = ['field:=' . $oldValue];

$this->typesenseClient->collections[$collection]->documents
            ->update($document, ['filter_by' => $filter]);

Expected Behavior

A successful API result and the target field is updated to 'new_value'

Actual Behavior

Exception thrown: Typesense\Exceptions\RequestMalformed For update, the id key must be provided.

Metadata

Typesense Version: Using typesense cloud API version 0.25.1

Typesense Client Version: 4.8.7

tykobradyer avatar Oct 20 '23 11:10 tykobradyer

Thank you for catching that.

@karakhanyans @arayiksmbatyan We need to add support for update by query, just like how we handle this in the typesense-js library: https://github.com/typesense/typesense-js/commit/1d34b880d47931d10bd974b41be49a6cf2918e95#diff-1e0565f0f17e3dfb64595df01f7506e4c30037e834ac03d758198f25e05c397eR228-R251

jasonbosco avatar Oct 20 '23 15:10 jasonbosco

Facing the same issue and shocked that this isn't already fixed, I provided a PR (#61)

regnerisch avatar Jun 12 '24 08:06 regnerisch