3

I am using Firebase RTDB to access my data using the Flutter app. The data has the following attributes:

{
  'Category': 'Food',
  'Product Description': 'Energy Drink',
  'Product Picture': 'image_link',
  'Product Title': 'Coca Cola',
  'Price': 40000,
  'inStock': 1,
  'keywords':[
    'coco cola',
    'energy drink',
    'drink',
    'other keywords'
  ]
}

I would like to use the keywords field to search for a specific product. How can I do that?

I know about 'orderby' and 'equalto' keywords in Firebase RTDB but how to use it with a list?

Or how do I change the structure of the data so that I can efficiently search for specific keywords?

  • 1
    Does this answer your question? [Firebase query if child of child contains a value](https://stackoverflow.com/questions/40656589/firebase-query-if-child-of-child-contains-a-value) – Wai Ha Lee Feb 04 '21 at 23:30
  • Have you found anything useful? – Reva Dec 21 '21 at 06:39

1 Answers1

1

Store the keywords as maps. So it would be like keywords: {'coca cola':true, ...}

Then you can do

.orderBy('keywords/coca cola').equalTo(true)
Syscall
  • 19,327
  • 10
  • 37
  • 52
FLjubic
  • 161
  • 1
  • 4