I'm doing a bulk indexing in AWS OpenSearch within my node application and it's failing because the chunk size are too big. Below is the error
Request size exceeded 104857600 bytes
So I need to calculate the actual chunk size in bytes. So I tried with below 2 ways and not sure which one is correct.
// with Buffer
const str = 'tree'
const obj = [{a:'sas'},{a:'e'}]
console.log(Buffer.from(str).length); ---> 4
console.log(Buffer.from(obj).length); ---> 2
// with object-sizeof
var sizeof = require('object-sizeof')
const str = 'tree'
const obj = [{a:'sas'},{a:'e'}]
console.log(sizeof(str)); ---> 8
console.log(sizeof(obj)); ---> 12
It seems 'Buffer' takes 1 Byte for a char while 'object-sizeof' takes 2 bytes for a char. So what is correct here? And which is the correct way to check the byte size of actual object array? Thanks in advance