I’ am working with typesense and firebase and I wa...
# community-help
g
I’ am working with typesense and firebase and I want to index a field type ‘ref’, Is there a way to transform the ref field to string when indexing? I was trying defining it with “string*” but no luck
j
@Guillermo Dorfman
ref
is an internal firebase field right?
The extension just goes off of whatever fields Firestore returns as part of this call: https://github.com/typesense/firestore-typesense-search/blob/1b9d22bc1e3fbb55fd548003abbadcbf2be8a3fc/functions/src/utils.js#L32
So if
ref
isn't returned by Firestore there, then the extension won't be able to sync it
g
I see,
else if (value instanceof admin.firestore.DocumentReference) {
return null;
}
j
Ahh, hmmm... May be we should just remove that else if block...
So it returns
value
from the
else
block
Could you open a Github issue for this? Happy to accept a PR for this, or I can take a look in a few days.
g
Great! I’m on it. We will have to see if then we can index that field to typesense in some way since its basically an object
Thanks Jason
j
Oh I see, if it is an object, then may be we should add that type to this else if block which handles objects: https://github.com/typesense/firestore-typesense-search/blob/1b9d22bc1e3fbb55fd548003abbadcbf2be8a3fc/functions/src/utils.js#L16
something like
else if ((typeof value === "object" && value !== null) || value instanceof admin.firestore.DocumentReference)
g
the documentReference has a property
path
that returns a string with the path inside the DB, maybe we could work with that
j
So may be we just sync
ref.path
as a field into Typesense?
g
That would work for me at least, I’m not sure if there’s another functionality of the ref field that somebody will need later
I created the issue, thanks Jason
👍 1
j
Following up from this: I think I misunderstood that you were going to do a PR for it... I'll take take a look later today and get back to you.
g
Ahh! I see, sorry I guess I could give it a try!
j
That would be great! Especially if you can test it as well with your project
g
Hi Jason, I can’t seem to be able to create a branch for the issue I created, maybe you have to assign it to me?
j
You would have to fork the repo, and then create a branch in your forked repo
👍 1
g
what params should I be giving the npm run emulator command?
npm run emulator
gives me
error: unknown option '--test-params'
With the typesense server I had no problem
j
Hmm, could you run
firebase --open-sesame extdev
first, and then try running the emulator?
g
npm run emulator:
ext:dev:emulators:start is no longer supported. Instead, navigate to a Firebase project directory and add this extension to the extensions manifest by running:
firebase ext:install
and when I try firebase extinstall
i  extensions: ensuring required API <http://firebaseextensions.googleapis.com|firebaseextensions.googleapis.com> is enabled...
Error: HTTP Error: 403, Permission denied to get service [<http://firebaseextensions.googleapis.com|firebaseextensions.googleapis.com>]
j
Hmmm, not sure why that error shows up. Could you just do a PR for whatever you have? I can then take it test it and take it from there
g
done, I literally just changed a single line in the code but I cannot test it 😅
j
Thank you for the PR @Guillermo Dorfman. I've posted an update on Github
🙌 1
g
It works great! You have to name the field ‘fieldname.path’ on the schema.
message has been deleted
j
Hmmm... In my tests it shows up as
ref.path
Is "consumer" the name of your firestore collection?
g
yes
This is the error on firestore when the typesense field was the same as the firestore collection
but naming the schema field consumer.path worked
That’s maybe something to add to the documentation.
j
@Guillermo Dorfman May I know what your firestore collection structure looks like that generates a
ref
key in the Firestore doc? I'm trying to replicate this on my Firestore collection