I am doing an ecommerce website and have a product collection using Mongodb. With the product I have 2 fields:
taxonomies: ['clothes', 'female', 'fashion']
attributes: [{'color': 'red'}, {'size': 'large'}, ...]
Now when user tries to search products by entering some keyword, I want to query the documents to see if any elements of the product's taxonomies or attributes contains that searching keyword.
Let's say the search keyword is 'fa', since the product I provided above as an example has 'fashion' taxonomy that contains 'fa', this product should be included in the search results. The same applies to attributes. So how may I accomplish that?