Skip to content

Commit

Permalink
Only log error documents in backfill log
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbosco committed Mar 12, 2024
1 parent 35e0b5e commit cff2cdb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Version 1.4.1

- Only log error documents in backfill log

## Version 1.4.0

- Shorten function names to fix issue with local emulator
Expand Down
2 changes: 1 addition & 1 deletion extension.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: firestore-typesense-search
version: 1.4.0
version: 1.4.1
specVersion: v1beta # Firebase Extensions specification version (do not edit)

displayName: Search Firestore with Typesense
Expand Down
18 changes: 16 additions & 2 deletions functions/src/backfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ module.exports = functions.firestore.document(config.typesenseBackfillTriggerDoc
currentDocumentsBatch = [];
functions.logger.info(`Imported ${currentDocumentNumber} documents into Typesense`);
} catch (error) {
functions.logger.error("Import error", error);
if (error.importResults) {
const failedItems = error.importResults.filter(
(r) => r.success === false,
);
functions.logger.error("Import failed with document errors", failedItems);
} else {
functions.logger.error("Import error", error);
}
}
}
}
Expand All @@ -71,7 +78,14 @@ module.exports = functions.firestore.document(config.typesenseBackfillTriggerDoc
.import(currentDocumentsBatch, {action: "upsert"});
functions.logger.info(`Imported ${currentDocumentNumber} documents into Typesense`);
} catch (error) {
functions.logger.error("Import error", error);
if (error.importResults) {
const failedItems = error.importResults.filter(
(r) => r.success === false,
);
functions.logger.error("Import failed with document errors", failedItems);
} else {
functions.logger.error("Import error", error);
}
}
}

Expand Down

0 comments on commit cff2cdb

Please sign in to comment.