meilisearch/firestore-meilisearch

How to index single fields inside an object from firestore documents

abdo400 opened this issue · 4 comments

Description
I have an object called name inside my documents, I wanted to index its fields which are name.en and name.fr, I wrote it while I index the document but after the script ran, the imported docs to the engine didn't have this property

Expected behavior
See the fields of the object name inside the engine

Current behavior
Fields don't exist

@alallema, I was talking with @abdo400 on the support. Can you confirm if the Firestore extension takes nested fields by default?

When @abdo400 left the field blank to specify the field to index, no content was sent to Meilisearch.

Hi @abdo400,
Sorry for the delay. The Firestore extension doesn't take nested fields into account, because Firestore calls it reference and gives a reference to another object in another collection. However, I think I understand here that it's not a reference you're trying to import, no?
Are you using the import script or does the problem occur when you import documents into Firestore that are not synchronized properly with Meilisearch?
Also which type of Field do you use on Firestore for your object name Map?

Edit: If you're talking about the map Firestore object and not the reference Firestore object, it should indeed be taken into account by default by the extension. Sorry for the misunderstanding

@alallema my impression when seeing this function
https://github.com/meilisearch/firestore-meilisearch/blob/main/functions/lib/meilisearch-adapter.js#L50-L73
is that it isn't recursive, so it will only index top level fields, I am not sure if that's the case though.

I have built similar code before, and each field should be checked if it's an Array or a JS Object, which would require recursion to include them in the final document.

Thank @ahmednfwela!
Yes, you're right. I don't think that's the case either - it would have to be tested, or a way out would have to be found.
@curquiza, @brunoocasali