#community-help

Discussing Firestore-Typesense Document Synchronization

TLDR Erick asked about using "optional": true when using the firestore-typesense-search extension and the impact of missing fields in schema on document updates. Kishore Nallan and Jason clarified how deletion and updates work between Firestore and Typesense.

Powered by Struct AI
39
20mo
Solved
Join the chat
Jan 14, 2022 (20 months ago)
Erick
Photo of md5-5d002d197dc556e6bc619deaa3a8aba7
Erick
01:22 PM
Is there anyone using firestore-typesense-search extension?
01:23
Erick
01:23 PM
01:25
Erick
01:25 PM
Jason
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:26 PM
Yes, please set "optional": true to the field configuration.
Erick
Photo of md5-5d002d197dc556e6bc619deaa3a8aba7
Erick
02:06 PM
When defining the schema?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:06 PM
Yes
Erick
Photo of md5-5d002d197dc556e6bc619deaa3a8aba7
Erick
02:06 PM
Nice
02:06
Erick
02:06 PM
Thanks!
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:06 PM
Welcome!
Erick
Photo of md5-5d002d197dc556e6bc619deaa3a8aba7
Erick
02:07 PM
I will post the answer and close the issue.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:07 PM
👍
Jan 15, 2022 (20 months ago)
Erick
Photo of md5-5d002d197dc556e6bc619deaa3a8aba7
Erick
01:43 AM
Hey Jason
01:43
Erick
01:43 AM
If I delete a document using optional=true on all fields
01:44
Erick
01:44 AM
Could this erase all variables for that document, even though de document didn't have this variables?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
01:45 AM
That should be possible...
Erick
Photo of md5-5d002d197dc556e6bc619deaa3a8aba7
Erick
01:45 AM
I'm referring to having a schema with more variables than the collection per se and erasing that firestore document
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
01:46 AM
Yup that should work
Erick
Photo of md5-5d002d197dc556e6bc619deaa3a8aba7
Erick
01:46 AM
Nice
01:46
Erick
01:46 AM
Thanks
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
01:46 AM
Documents are deleted by ID, so when a document is deleted all fields in it are deleted fully
Erick
Photo of md5-5d002d197dc556e6bc619deaa3a8aba7
Erick
01:46 AM
Nice
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
01:46 AM
regardless of whether the fields are mentioned in the schema or not
Erick
Photo of md5-5d002d197dc556e6bc619deaa3a8aba7
Erick
01:46 AM
Well
01:47
Erick
01:47 AM
the fields are mentioned in the schema
01:47
Erick
01:47 AM
the firestore document is the one that doesn't have them
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
01:47 AM
As long as it just has an ID, which I believe all Firestore docs have
Erick
Photo of md5-5d002d197dc556e6bc619deaa3a8aba7
Erick
01:47 AM
Sort of like having two sources of truth for one document
01:47
Erick
01:47 AM
two*
01:48
Erick
01:48 AM
Ok
01:48
Erick
01:48 AM
The synchronization is the same
01:48
Erick
01:48 AM
Another question
01:49
Erick
01:49 AM
If I update that document on firestore, should the missing values on that document affect the whole record on typesense?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
01:51 AM
To make sure I understood you, you're asking if you delete a field from a Firestore document, will that field get deleted in the corresponding document in Typesense as well? - If so, yes
Erick
Photo of md5-5d002d197dc556e6bc619deaa3a8aba7
Erick
01:52 AM
Meaning that if I send the firestore document minus 3,4,5, etc... fields (since the collection has less values than the schema definition), could the update/modify these missing values in case they were previously added?
01:54
Erick
01:54 AM
For example, I define the schema with 5 fields (all of them optionals), my firestore collection with 3 fields.
01:54
Erick
01:54 AM
I create a document and then after that creation, I update the other 2 fields.
01:54
Erick
01:54 AM
Then I perform an update.
01:55
Erick
01:55 AM
Would this update affect those 2 fields?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:35 AM
Yeah, with every update to the firestore document, the entire firestore document is synced over to Typesense and replaced fully with the contents of the document in Firestore