firecmsco / firecms

Awesome Firebase/Firestore-based CMS. The missing admin panel for your Firebase project!
https://firecms.co
Other
1.13k stars 185 forks source link

Searching a collection group through textSearchController #571

Open faizanabidnaqvi opened 10 months ago

faizanabidnaqvi commented 10 months ago

Hi!

I am not sure if this is a bug or a feature request. I tried using textSearch on a collection group by adding textSearchEnabled: true to the group. I also set up a search index based on the path. This resulted in showing the search bar in a collection group view.

However, I can't make it work. Seems like the data source searches based on a path like 'locale' so when we return ids from the text search controller, it will look for a doc like locales/[id] in firebase which is incorrect for a collection group based on a subcollection.

It would be nice if we could return a full doc path instead of just an id through the textSearchController; so we can return something like testDocs/flAzEev0jUq9G9YONPuX/locales/en-US and show the searched entities in the collection group view. This can be accomplished in Algolia either by setting the objectID to the full path or adding an additional path field in Algolia for an entity.

I understand that I can accomplish this through a custom data source which I will be trying in a couple of days but not sure if the collection group view will handle it correctly.

fgatti675 commented 10 months ago

Hi @faizanabidnaqvi That's an interesting use case. So you are indexing all locales in a custom index?

faizanabidnaqvi commented 10 months ago

Hey!

Thanks for getting back. Yes, I was thinking of indexing all locale subcollections docs in a single algolia index with the path being the object id.

That would make it easy to search all locales (in each locale subcollection), to find a certain term for example.