algolia / firestore-algolia-search

Apache License 2.0
112 stars 35 forks source link

Transform data when using a full sync #83

Closed jdmeyer3 closed 2 years ago

jdmeyer3 commented 3 years ago

Is it possible to transform the data before loading it to Algolia when using the script npm firestore-algolia search?

smomin commented 3 years ago

I don't really understand you question. Can you provide more detail?

jdmeyer3 commented 2 years ago

With the extension, I can specify a transformer function to manipulate the data before it is sent to Algolia. With the bulk load, is there any way to specify a function or use some transform code before sending the data to Algolia.

smomin commented 2 years ago

You should be able to do an import process executed on your local instance using the command below. The script will call the Transform function to do any preprocessing before sending to Algolia. I hope this helps.

LOCATION=<location of cloud function>\
  PROJECT_ID=<firebase-project-id>\
  ALGOLIA_APP_ID=<algolia-app-id>\
  ALGOLIA_API_KEY=<algolia-api-key>\
  ALGOLIA_INDEX_NAME=<algolia-index-name>\
  COLLECTION_PATH=<firebase-collection-path>\
  FIELDS=<comma separated fields params>\
  TRANSFORM_FUNCTION=<cloud-function>\
  GOOGLE_APPLICATION_CREDENTIALS=<location of the service json on local environment>\
  npx firestore-algolia-search

You should be able to find the above command prepopulated with your setting in the Algolia firebase extension configuration.

smomin commented 2 years ago

Closing due to no response. Please reopen if the issue still exists.

maderesponsively commented 1 year ago

I'm utilizing the Firebase extension to synchronize my Firestore collection with Algolia search. As part of this process, I've set up a transformation function to replace category IDs in my Firestore documents with the actual category names before they're indexed in Algolia.

I've observed that the transformation works perfectly when I modify individual Firestore documents. The changes reflect correctly in Algolia search results. However, when I save changes in the Firebase extension settings, it seems that the transformation is not triggered on all documents. My assumption is that the transform function is only invoked on individual document changes and not when bulk updates are made through the extension.

Is this the intended behavior? If so, is there a recommended way to ensure transformations are applied consistently, even during bulk updates? Or is there something else I might be missing in my configuration?

Thank you for your assistance.