Forum
Complex category filtering
I have a collection of Projects, related to Churches. The Projects are in categories, and so are the Churches.
I can filter by the categories associated with the Projects easily, and that's working great. What I can't do is filter on the categories associated with the related churches (say I want all projects related to churches in the borough of Ealing). Do you have a suggested way of working for this?
Also, is there a way to choose some categories as "AND" matches, and some as "OR" matches, and maybe in groups?
Eg, say I want all Projects that are Addiction projects OR Health projects, within the boroughs of Ealing OR Barnet for example. Any idea how you would do this?
I guess I may have to use Perch to output multiple arrays, and then use PHP to work out the intersections between those arrays? Just wondered if there's a built in method, or a way others have tackled this in the past?
Is it any easier if I make my Areas/Boroughs into collections, rather than categories?
Have figured this out by doing a couple of extra calls to perch_collection() and then doing an intersection on the IDs to get the ids I need, then in my final call to perch_collection() I'm filtering on the _id (or church._id as appropriate).
Ok, sounds good.