I'm using Firestore to store data for multiple entities. In this example, each document is a company with details on the products it sells, and each product is associated with multiple keywords. Example structure:
Document 1:
company_name: 'Company 1',
products: [
{
name: 'Green tea',
keywords: ['green tea', 'healthy, 'matcha']
},
{
name: 'Sushi',
keywords: ['sushi', 'rice', 'healthy']
}
]
Document 2:
company_name: 'Company 2',
products: [
{
name: 'Apple',
keywords: ['fruit', 'healthy']
},
{
name: 'Cake',
keywords: ['dessert', 'sweet']
}
]
I would like to search for companies that sell products with certain keywords. For example, by searching for the keyword healthy
, both documents Company 1
and Company 2
would be returned, as they both sell foods with that keyword. How would I do this with Firestore filtering/searching?