algolia / firestore-algolia-search

Apache License 2.0
112 stars 35 forks source link

Bug v1.1.3 - Collection and Subcollenction with same name #171

Closed maiconkf closed 11 months ago

maiconkf commented 1 year ago

I have these collections: events users > events

Algolia is getting the users/events instead of getting events

image

Edit: This only occurs in existing records. New records do not experience this issue

smomin-bd commented 1 year ago

Can you provide step by step details when it works and when it doesn't work?

guskuma commented 1 year ago

This just happened with me too.

my collection path: 'customers/{uid}/referreds' documents getting indexed from 'customers/{uid}/imports/{importid}/referreds'

I still didn't notice if it happens with new records but with existing it surely do.

fringley commented 11 months ago

This is also happening to me now (didn't seem to in older versions).

My collection path is organisations/{orgId}/users which is also indexing the root collection users which is then overwriting the correct collection objects.

EDIT: This could actually be a bug with the initial filling of the collection using the Full Index existing documents? feature set to TRUE

smomin commented 11 months ago

unfortunately there is no api available to target a sub-collection. in order to support sub-collections indexing, Firebase team recommended I use the collectionGroup api which grabs all collections with the collection name, e.g. users. if Firebase team enables better targeting of subcollections, i will implement it. for now, i am closing this since there is not an approach to resolve this issue.

fringley commented 11 months ago

Taking a look through the full indexing feature - it does appear that the collectionGroup search is used when the Collection Path doesn't begin with a /.

It would be helpful to update the documentation for the collection path to indicate that it will use a collectionGroup query if the Collection Path does not start with a slash.