#community-help

Troubleshooting Document Insertion to Collection

TLDR Vishal had trouble inserting documents into the collection. Jason suggested reading the response body for errors. Issue was likely due to non-optional fields in the schema.

Powered by Struct AI
white_check_mark1
10
3mo
Solved
Join the chat
Jun 09, 2023 (3 months ago)
Vishal
Photo of md5-178450ab9171fe1c7eba3a5eb7e1a312
Vishal
09:02 PM
I am trying to insert documents into the collection - I don't get any error logs (via python) so I don't know what the issue is but it is not actually inserting the data into the collection - is there a way to troubleshoot document insertion to a collection?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:13 PM
The import endpoint always returns a 200, to account for partial successes/failures. So you want to read the response body and look for the error there
Vishal
Photo of md5-178450ab9171fe1c7eba3a5eb7e1a312
Vishal
09:14 PM
hmm I am using the python library, is there a way to have it print to the console?
09:21
Vishal
09:21 PM
ok, will do them one row at a time, I am getting some error output for one row
09:23
Vishal
09:23 PM
hmm, you can insert a document with lesser keys then is defined in the schema correct?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:24 PM
Only if you’ve marked those fields as optional in the schema
Vishal
Photo of md5-178450ab9171fe1c7eba3a5eb7e1a312
Vishal
09:26 PM
ahh, ok, hopefully that solves it, testing
09:27
Vishal
09:27 PM
during upsert is that also true
09:28
Vishal
09:28 PM
(eg can you update only one field in a schema even if there are several fields that are not marked as optional)
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:29 PM
Upsert requires the full document as well.

Update and emplace accept partial documents: https://typesense.org/docs/0.24.1/api/documents.html#action-modes-batch-create-upsert-update-emplace
white_check_mark1