Resolving Typesense Document Import Error
TLDR David struggled with accessing error.importResults
from a failed document import with Typesense. After advice from Jason, the issue was resolved by logging each unsuccessful document through a for loop.
1
Oct 22, 2022 (14 months ago)
David
07: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
04:52 PMJason
04:52 PMDavid
04:54 PMJason
04:56 PMOct 24, 2022 (14 months ago)
David
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}`);
}
}
}
1
Typesense
Indexed 3015 threads (79% resolved)
Similar Threads
Troubleshooting Typesense Errors in NestJS Project
Iulian is experiencing Typesense errors in a NestJS project. Kishore Nallan and Jason provide advice, suggesting try-catch and looking at code snippets respectively.
Resolving JSON Parsing Error in Import Function Implementation
Harpreet experienced a JSON parsing failure while implementing an import function. Kishore Nallan suggested double escaping characters in the JSON objects. After testing and discussion, both agreed that the error resulted from not handling JSON-encoded strings manually. Harpreet decided to update the test cases accordingly.
Discussing TypeSense Setup & Documentation Improvements
Harrison faced challenges with TypeSense setup and documentation. Jason clarified reasons behind the method used for handling bulk imports and explained the HTTP response. They acknowledged Harrison's points and agreed about improving the documentation.