#community-help

Updating Documents and Fixing Error in Prod Environment

TLDR sahubar asked to update documents except for certain id fields. Kishore Nallan shared a future feature addressing this. Then, sahubar encountered an error in their prod environment. Kishore Nallan provided potential reasons and a temporary solution.

Powered by Struct AI

1

15
3mo
Solved
Join the chat
Jul 01, 2023 (3 months ago)
sahubar
Photo of md5-41ca8b93efee2249950bdd80b036a9dc
sahubar
10:31 AM
Greetings of the day...

Hi Jason / Kishore Nallan
if possible update the document except for the id field like (product_id,item_code,model_code ) it could be better for multiple update documents based some other fields
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:38 AM
You want to update some fields based on a filter condition?
sahubar
Photo of md5-41ca8b93efee2249950bdd80b036a9dc
sahubar
10:40 AM
thanks, for the quick reply Kishore Nallan
yes i need update documents except id field
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:43 AM
Feature is available in upcoming 0.25 release. Example:

export FILTER_CLAUSE="points:1000"
curl "" -X PATCH \
        -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -d '{"title": "Title with 1000 points."}'

The above will update the title of all documents that has a points field value of 1000.

Is this what you want?
sahubar
Photo of md5-41ca8b93efee2249950bdd80b036a9dc
sahubar
10:53 AM
yes Kishore Nallan its working fine thanks for the update

1

11:01
sahubar
11:01 AM
Kishore Nallan below mentioned error thows prod environment

{
"message": "Not Ready or Lagging"
}
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:02 AM
What command did you run?
sahubar
Photo of md5-41ca8b93efee2249950bdd80b036a9dc
sahubar
11:05 AM
curl --location --request PATCH 'https://mycluter.typesense.net/collections/myproducts/documents?filter_by=mymodel_code:"gripp-focal-camera-lens-2-in1-protection-tempered-glass-for-apple-iphone-14-14-plus"' \
--header 'X-TYPESENSE-API-KEY: mytypesensekey' \
--header 'Content-Type: application/json' \
--data-raw '{
"rating": 5,
"review_count" : 81
}'
11:06
sahubar
11:06 AM
i have tried dev and stage its working but my prod its throws error above mentioned
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:10 AM
Commands that touch the whole cluster can take some time to finish
sahubar
Photo of md5-41ca8b93efee2249950bdd80b036a9dc
sahubar
11:12 AM
ok Kishore Nallan i will check and revert back to you
11:14
sahubar
11:14 AM
FYI
Image 1 for FYI
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:15 AM
Try again now.
11:16
Kishore Nallan
11:16 AM
There was probably a bad query that was hogging the CPU. We have better mechanism for this in recent builds. I've fixed this for you for now.
11:17
Kishore Nallan
11:17 AM
I see all requests being sent to only 1 node on your cluster.