#community-help

Typesense Multi-Tenant Updates & Webhooks

TLDR Campbell sought methods for detecting changes in Typesearch index and webhook. Jason recommended using last updated timestamp and triggering a webhook from the primary datastore.

Powered by Struct AI

1

Feb 24, 2023 (10 months ago)
Campbell
Photo of md5-a51fb0482e5dbe39a8022f2a541f1e27
Campbell
11:44 PM
Hello all. We're working on using typesense multi tenant capability for multiple headless ecom sites with next.js. Does anyone have suggestions on how you handle detecting changes in typesearch index and then updating any affected products/content?

We're adding a unixtimestamp value to each doc so that we know the last time it was update, so we can simply query the index using a 'since' argument to get any changes, but I'm wondering if there's a more efficient way to handle this?

Is there a way to determine when the index as a whole was lasted updated? Maybe we can add a collection with a doc and timestamp that we update any time a doc is updated, and we just query that field, and if changed, we query the product collections to get changes.

Even better, has anyone created a webhook capability that would fire any time the index is updated?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
11:46 PM
Using a last updated timestamp and detecting changes based on that is one of the recommended ways: https://typesense.org/docs/guide/syncing-data-into-typesense.html#polling-your-primary-database

You’ll find other options mentioned in that article…
11:47
Jason
11:47 PM
> Is there a way to determine when the index as a whole was lasted updated?
You could sort desc by the since field you mentioned
11:48
Jason
11:48 PM
> has anyone created a webhook capability that would fire any time the index is updated?
I’d imagine you would need a webhook / trigger to fire from your primary datastore right? Not on the Typesense side?
Campbell
Photo of md5-a51fb0482e5dbe39a8022f2a541f1e27
Campbell
11:50 PM
That makes sense. Webhook fires on primary datastore once the typescript index is updated with any changes.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
11:51 PM
You want to do the other way around - meaning you’d first write the data to your primary data store, then a trigger fires from your primary data store, a listener then indexes the data into Typesense (which is a synchronous process)
Campbell
Photo of md5-a51fb0482e5dbe39a8022f2a541f1e27
Campbell
11:52 PM
yeah, that's what we're doing - we just need to add the webhook at the end of that process.
11:53
Campbell
11:53 PM
Thank you Jason.

1

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3015 threads (79% resolved)

Join Our Community

Similar Threads

Handling Order of Firestore Events for Synchronization with Typesense.

Ross ran into an issue with Firestore events triggering out of order, causing synchronization inconsistency between Firestore and Typesense. With advice and input from Jason and Kishore Nallan, they implemented a debouncing solution using redis, ensuring that the latest Firestore data is synced to Typesense accurately.

3

41
19mo

Troubleshooting 409 Errors with Firestore to Typesense Cloud Function

Orion encounters 409 errors with `ext-firestore-typesense-search-indexToTypesenseOnFirestoreWrite` cloud function. Jason suggests possible solutions like querying Firestore on each change or tracking sync state in a collection. Both agreed on adding a config option. Orion proposed contributing a PR for the change.

3

47
10mo

Typesense Firestore Real-Time Update Query

DomijKu required help with real-time updates on frontend when backends changes occur. Jason, CaptainCodeman and Loic explained triggering updates via direct subscription to Firestore, cloud function triggers, and stream subscriptions. Loic recommended switching to Typesense for searches beyond 20 documents.

4

10
19mo

Troubleshooting Typesense Document Import Error

Christopher had trouble importing 2.1M documents into Typesense due to memory errors. Jason clarified the system requirements, explaining the correlation between RAM and dataset size, and ways to tackle the issue. They both also discussed database-like query options.

3

30
11mo

Troubleshooting 400 Error When Upgrading Typesense Firestore Extension

Orion experienced a `400` error after updating the Typesense Firestore extension, causing issues with cloud functions. They traced the issue back to a data type conflict in their Typesense collection schema after updating. With help from Jason and Kishore Nallan, they resolved the issue by recreating the collection.

5

96
14mo