I’m designing an app that would allow a user to find items that fit certain diets. These diets include vegan, gluten free, organic, kosher, soy free, etc.
If a user has multiple dietary needs, for example, they may want gluten free/vegan/soy free items, I only want them to see items that are gluten free AND vegan AND soy free. So if an item is only gluten free and vegan, but not soy free, the item will be filtered out and the user will not see that item.
I came up with a solution, but it uses “Advanced” in the filter feature. The problem is, this results in an extremely slow app in filtering through and getting the results.
What I did:
I created a type ‘diet’ with a field called ‘name’ of type text. So I have diets, named: Vegan, Gluten Free, Soy Free, etc.
I created a type food item with a field called ‘diets’ which is multiple texts (as an item can fit multiple diets). So I can create a food item named sandwich and can assign it a diet: gluten free, vegan, soy free.
I have users with field ‘diets’ where in my app the user can indicate their diet to be of multiple diets.
So now I do a search for all items:filtered:advanced:this items diets intersect with the user’s list of diets: count >= the user’s list of diets:count
What this does is when I intersect the diets of an item with the user’s diets, I filter on only items that have all of the diet’s the user has entered. As stated before, however, this has become a very slow process.
Any ideas on an alternative method would be greatly appreciated.
