Dande132
Dande132

Reputation: 5

Flutter Firebase - retrieving data using where in a collection with multiple docs

Hi I'm trying to retrieve data from FireBase using the input by the user in the search bar. The db struture is like this: DB struture Where every doc inside the collection "catalog" have one aditional collection named "recipes" and inside "recipes" are recipes with titles. Example DB struture

How I can compare the input of the user with all recipes inside of all docs?

Currently using this code it works for 1 doc: Code

Upvotes: 0

Views: 28

Answers (1)

Rafael Zasas
Rafael Zasas

Reputation: 993

If you want true full text search capabilities you will need to use a tool designed for that problem like Elastic Search, Typesense or Algolia.

Each of these are standalone services that can be used, but have very seamless integrations when using them as part of Firebase Extensions. Extensions will however need a credit card on file to be enabled.

Note that each of these may have cost implications, and limitations on how to structure your database. Algolia for example requires your text searchable entries to be in one collection.

You might then use a Firestore structure as follows:

foodTypes > meat > recipes > <recipe Id>

where meat and recipes are sub collections.

Upvotes: 1

Related Questions