typesense / firestore-typesense-search

Firebase Extension to automatically push Firestore documents to Typesense for full-text search with typo tolerance, faceting, and more
https://extensions.dev/extensions/typesense/firestore-typesense-search
Apache License 2.0
158 stars 34 forks source link

Firebase Extension incorrect parsing of `object[]` into `geopoint[]` #84

Closed buy closed 2 months ago

buy commented 2 months ago

Description

Update: I found the logic here https://github.com/typesense/firestore-typesense-search/blob/b9b89bf2b8f36478967f5d17f1139597c65b8936/functions/src/utils.js#L8-L9

Now the ask: is it possible to provide an option to bypass this behavior? Or only convert if the object has no other fields? aka only parse fieldName: {lat: ..., lng: ...}

---- Original Description ---- I noticed an issue when the extension synced on write, it incorrectly converted the following object[] into geopoint[]. The expected behavior should be object[] or at least configurable:

input field

"locations": [
    {
      "city": "New York",
      "county": "New York",
      "state": "NY",
      "zipCode": "10465",
      "latitude": 0,
      "longitude": 0
    }
  ],

output field before sending to backend

"locations":[[0,0]]

Steps to reproduce

Trigger Firebase extension sync, with the above mentioned object field structure. My guess is the extension saw lat/lng and it has logic to parse to latitude and longitude.

Expected Behavior

Object being parsed as-is, using object[]

Actual Behavior

Smart parsed into geopoint[], thus losing a lot of fields and changed the underlying data structure

Metadata

Typesense Version: typesense/firestore-typesense-search@1.4.0 backend: 0.26

OS: docker

buy commented 2 months ago

Yep, exactly, is it possible to provide a flag so we can bypass this behavior? https://github.com/typesense/firestore-typesense-search/blob/b9b89bf2b8f36478967f5d17f1139597c65b8936/functions/src/utils.js#L8-L9

jasonbosco commented 2 months ago

@buy We've published a fix for this issue in v1.5.0-rc.0.

Could you use this installation link and confirm if the issue is indeed resolved with your dataset: https://console.firebase.google.com/project/_/extensions/install?ref=typesense/firestore-typesense-search@1.5.0-rc.0

buy commented 2 months ago

@jasonbosco Awesome! Thank you so much for the quick turnaround, I will give it a try later this week and let you know.