Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for subcategory backfill (redo) #93

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ When you install this extension, you'll be able to configure the following param

| Parameter | Description |
|-----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Firestore Collection Path | The Firestore collection that needs to be indexed into Typesense. |
| Firestore Collection Path | The Firestore collection that needs to be indexed into Typesense. Supports [subcollection wildcards](https://firebase.google.com/docs/functions/firestore-events?gen=2nd#wildcards-parameters) the following way: `users/{userId}/orders` where `{userId}` is a wildcard for all documents in the parent collection. |
| Firestore Collection Fields | A comma separated list of fields that need to be indexed from each Firestore document. Leave blank to index all fields. |
| Flatten Nested Documents | Should nested documents in Firestore be flattened before they are indexed in Typesense? Set to "Yes" for Typesense Server versions v0.23.1 and below, since indexing Nested objects is natively supported only in Typesense Server v0.24 and above. |
| Typesense Hosts | A comma-separated list of Typesense Hosts (only domain without https or port number). For single node clusters, a single hostname is sufficient. For multi-node Highly Available or (Search Delivery Network) SDN Clusters, please be sure to mention all hostnames in a comma-separated list. |
Expand Down
11 changes: 10 additions & 1 deletion functions/src/backfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@ module.exports = functions.firestore.document(config.typesenseBackfillTriggerDoc

const typesense = createTypesenseClient();

const querySnapshot = await admin.firestore().collection(config.firestoreCollectionPath);
const isSubcollection = config.firestoreCollectionPath.includes("/");
let query;
if (isSubcollection) {
const collectionGroup = config.firestoreCollectionPath.split("/").pop();
query = admin.firestore().collectionGroup(collectionGroup);
} else {
query = admin.firestore().collection(config.firestoreCollectionPath);
}

const querySnapshot = await query;

let lastDoc = null;

Expand Down
Loading