David Paulsson
10/22/2022, 7:45 AM[Typesense] Could not create document: ImportError: 913 documents imported successfully, 9 documents failed during import. Use `error.importResults` from the raised exception to get a detailed error reason for each document.
I'm struggling how see the error.importResults
(i.e. I'm doing it wrong haha).
I'm doing something like this and none of the console logs in the catch prints what I'm after so I can debug and fix the documents that fail to import
try {
const res = await typesenseClient
.collections(collection)
.documents()
.import(searchIndex, { action: 'upsert' });
} catch (error) {
console.log(error);
console.log(error.importResults.filter((r) => r.success === false));
error.importResults
.filter((r) => r.success === false)
.forEach((r) => {
console.log(r);
});
}
Jason Bosco
10/22/2022, 4:52 PMJason Bosco
10/22/2022, 4:52 PMDavid Paulsson
10/22/2022, 4:54 PMJason Bosco
10/22/2022, 4:56 PMDavid Paulsson
10/24/2022, 11:04 AM} catch (error) {
for (let i = 0; i < error.importResults.length; i++) {
if (error.importResults[i].success === false) {
console.log(`Error With Document: ${error.importResults[i].error}`);
}
}
}