Yoghee
Yoghee

Reputation: 21

How to get data from subcollections in firestore Flutter?

I have an firestore database with collection -> Document -> many sub-collections. I need to get all data from all sub-collections using FirebaseFirestore.instance... firestore

I have to create a search button in flutter which takes all the data from firestore so as to allow searching for each collection instead of searching on a single one. code 1

code 2

Upvotes: 2

Views: 159

Answers (1)

Codrut Erdei
Codrut Erdei

Reputation: 104

Searching between multiple subcollections is not really advised due to the fact you have to search each individual collection and firestore's pricing model will tax you for each search (even tho you get no result) as a document read, and at scale, it will affect greatly.

What you could do is to make a separate search collection that you sync with Algolia (or another search service, but this one has a firebase extension to help you do that) because in firebase you can't full-text search.

Upvotes: 1

Related Questions