#community-help

Discussing Firebase Extension and Timestamp Implementation.

TLDR Loic enquired about timestamp inf Firebase implementation. Jason confirmed it's supported and shared the extension version, its functionality, and where the conversion happens. Loic planned to test this.

Powered by Struct AI

2

May 12, 2022 (20 months ago)
Loic
Photo of md5-3a88a602e4aba6a18b4a6c6985fcf08c
Loic
12:27 AM
hi Jason, are you planning to implement the timestamp like firebase in the field types?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:28 AM
Loic A contributor recently added support for this, along with nested fields in the extension
12:28
Jason
12:28 AM
So the Firebase extension will automatically convert Firebase data types to Typesense data types
12:28
Jason
12:28 AM
in this case, dates will be converted to unix timestamps automatically
Loic
Photo of md5-3a88a602e4aba6a18b4a6c6985fcf08c
Loic
12:29 AM
Is it live already on the current Firebase extension and schema v0.22.2?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:29 AM
Yup, you want to use v0.3.0 of the extension
Loic
Photo of md5-3a88a602e4aba6a18b4a6c6985fcf08c
Loic
12:29 AM
So in the schema you put int64 as field type to receive the timestamp data?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:29 AM
Correct
Loic
Photo of md5-3a88a602e4aba6a18b4a6c6985fcf08c
Loic
12:30 AM
Perfect thank you. Do you know if it converts the timestamp in DateTime.now().millisecondsSinceEpoch ?
Loic
Photo of md5-3a88a602e4aba6a18b4a6c6985fcf08c
Loic
12:31 AM
Yes, Math.floor(value.toDate().getTime() / 1000);
12:32
Loic
12:32 AM
I don’t know if it millisecondsSinceEpoch or millisecond
12:32
Loic
12:32 AM
I will try it out
12:32
Loic
12:32 AM
Thank you Jason
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:32 AM
:thumbsup:
Loic
Photo of md5-3a88a602e4aba6a18b4a6c6985fcf08c
Loic
12:33 AM
congrats on the Google IO featured 🔥
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:33 AM
Thank you! 😄
Loic
Photo of md5-3a88a602e4aba6a18b4a6c6985fcf08c
Loic
08:18 PM
Hi Jason ,
I was able to send Timestamp from Firebase -> to Typesense int64
When I do the other way, I search and receive the int64 in my app and it is the same value as in Typesense ✔️

However, this Timestamp (for example: 1652386231) is supposed to be in millisecondsSinceEpoch but for some reason if I want to compare a date I have to use the received Timestamp as millisecondsSinceEpoch but the other date as seconds

For example if I get the lastConnection from a Typesense search and I then want to compare I have to do:
lastConnection.millisecondsSinceEpoch > Timestamp.fromDate(DateTime.now().subtract(const Duration(seconds: 70))).seconds
08:20
Loic
08:20 PM
It seems to me that the Timestamp conversation is not going well in the process
08:20
Jason
08:20 PM
Notice the / 1000 part
Loic
Photo of md5-3a88a602e4aba6a18b4a6c6985fcf08c
Loic
08:21 PM
Yes but in reality it is not was it does. The Timestamp in Firebase is in nanoseconds.

Example of timestamp in second: 1652386236
Example of timestamp in millisecond: 1652386236975
Example of timestamp stored in typesense: 1652386231
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
08:22 PM
Hm are you sure? Current epoch time is 1652386958: https://www.epochconverter.com/
08:23
Jason
08:23 PM
Just saw your edit

1

08:23
Jason
08:23 PM
You should see timestamps stored in seconds in Typesense
Loic
Photo of md5-3a88a602e4aba6a18b4a6c6985fcf08c
Loic
08:26 PM
Ok, I will edit everything for seconds then. 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

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

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

Resolving Typesense Cloud and Firebase Timestamp Error

Eoin faced an issue with Firebase timestamp when setting up Typesense Cloud. Jason suggested converting timestamps to Unix and sync them as int64 fields in Typesense.

18
25mo

Resolving Typesense 0.22.2 Syntax Error and Import Issues

John faced issues with Typesense 0.22.2 code syntax and import functionality. Jason advised to reformat the JSONL records into single lines, increase ulimit, and convert dates to int64 format manually in code. A typo in the code was also corrected.

8

30
21mo

Sorting Results in Typesense and Handling Errors

Ramees asks about sorting results by distance in Typesense, entering a list of strings as a field, and resolving an error with `fields` format. Kishore Nallan assists with these issues and advises on storing timestamps and proper authentication.

2

46
30mo