Aljosa Asanovic
11/08/2021, 10:46 PMAljosa Asanovic
11/08/2021, 10:49 PMJason Bosco
11/08/2021, 11:04 PMbatch_size
parameter you mention is actually a Typesense server parameter which does something different - server-side batching, after ever X documents imported, it will pause and look at the search request queue services those and then get back to importing.Aljosa Asanovic
11/08/2021, 11:06 PMAljosa Asanovic
11/08/2021, 11:06 PMJason Bosco
11/08/2021, 11:07 PMAljosa Asanovic
11/08/2021, 11:07 PMbatch_size
parameter, I believe this is a documentation bug then ?Jason Bosco
11/08/2021, 11:09 PMYup, Typesense Server only accepts JSONL for import, so the client converts arrays to JSONL before making the API callAlso notice how that method calls JSON.stringify on the entire array object. That's what causes the issue. One thing we could do is to split large arrays into smaller ones, then call JSON.stringify on them indvidiually and then concat them together. So users of the client library don't have to do this themselves...
Jason Bosco
11/08/2021, 11:10 PMAs for the batch_size parameter, I believe this is a documentation bug then ?The parameter still works from Typesense Server's perspective, we need to add it to Typescript types and clarify in the docs what it exactly means. It doesn't control client-side batching, only server-side batching
Jason Bosco
11/08/2021, 11:13 PMAljosa Asanovic
11/08/2021, 11:15 PMAlso notice how that method calls JSON.stringify on the entire array object. That's what causes the issue. One thing we could do is to split large arrays into smaller ones, then call JSON.stringify on them indvidiually and then concat them together. So users of the client library don't have to do this themselves...I guess I must be close to the limit with the additional manipulations I do on the raw json I post to my server since I'm able to split the json using the same
.map()
used in typesense js
The parameter still works from Typesense Server's perspective, we need to add it to Typescript types and clarify in the docs what it exactly means. It doesn't control client-side batching, only server-side batchingUnderstood 🙂 , I know what you mean now with regard to my initial question being about batching before sending. And I appreciate the issue having been created! Will
batch_size
actually be sent correctly then to the server if I add it to the options of the import()
call ?Aljosa Asanovic
11/08/2021, 11:15 PMJason Bosco
11/08/2021, 11:17 PMWill batch_size actually be sent correctly then to the server if I add it to the options of the import() call ?Yup it should be sent. Do you want to create PR adding this to the types?
Jason Bosco
11/08/2021, 11:18 PMDocumentWriteParameters
and add batch_size to thatAljosa Asanovic
11/08/2021, 11:20 PMDocumentImportParameters
?Jason Bosco
11/08/2021, 11:24 PM