#BULK_UPDATE I want to use bulk update for optiona...
# community-help
b
#BULK_UPDATE I want to use bulk update for optional fields to applicable documents in a Collection.
@Jason Bosco
This is my schema
Copy code
"fields": [
        { "name": "id", "type": "string", "index": true },
        { "name": "sku", "type": "string", "index": true, "sort": true, "infix": true, "facet": true },
        { "name": "description", "type": "string", "index": true, "sort": true, "infix": true, "optional": true },
        { "name": "categoryId", "type": "string", "index": true, "optional": true, "facet": true },

...
I load id/sku/description from first source. Let's say 50K documents Now I want to update categoryId from different source for applicable sku.
curl "${TYPE_SENSE_HOSTURL}/collections/${2}/documents/import?action=update
my JSONL
Copy code
{"sku":"00010121","categoryId":"200", "subCategoryId":"2010"}
{"sku":"00010464","categoryId":"300", "subCategoryId":"3070"}
{"sku":"00010715","categoryId":"300", "subCategoryId":"3070"}
{"sku":"00010721","categoryId":"300", "subCategoryId":"3070"}
However we get error {"code":400,"document":"{\"sku\":\"00010121\",\"categoryId\":\"200\", \"subCategoryId\":\"2010\"}\r","error":"For update, the
id
key must be provided.","success":false} {"code":400,"document":"{\"sku\":\"00010464\",\"categoryId\":\"300\", \"subCategoryId\":\"3070\"}\r","error":"For update, the
id
key must be provided.","success":false} Q1# do I have to update only on
Id
field Q2# Can I update with
sku
fields? in both curl and sdk ? Appreciate your time and help
j
You’d need to identify the record to update by specifying the ID field - that’s the only way to update a record. But you can specify any other fields to update
So if your JSONL file looks like this:
Copy code
{"id: 123, "sku":"00010121","categoryId":"200", "subCategoryId":"2010"}
That means, in the record with
id: 123
, update sku to
00010121
, categoryId to 200, subCategoryId to
2010
b
So there is no feature like
update-where
?
j
No. So you’d want to run the update where query on your primary data-store, get the IDs and then update Typesense
b
got it. let me try that. Thanks
👍 1
j
@Babin Update-where just landed in an RC build 🙂 https://github.com/typesense/typesense/issues/496#issuecomment-1473119885
Let me know if you’d like us to upgrade your cluster to this build