Multiple Filters to Refine Repeating Group

Hi @arrev :slight_smile: Happy to take a look at this! And you’re exactly right, this is trickier to set up with many “OR” possibilities!

There are a few different methods for querying the data. With smaller amounts of data I would recommend using merged searches, but it may not be the best approach for your app since you could have thousands of movies in your database, and running many merged searches multiple times every time a User changes the filtering will eat up a lot of capacity.

One alternative is to use advanced filtering on the search for Movie Entries, but filtering can be really slow when you have a ton of entries in the database as well. It is probably worth considering to restructure the data, and create new data types for “Genre”, and “Streaming Service”, and within each of those data types, you could have a list of Movies field (which stores all of the Movies in that Drama, or available on that Streaming Service). I’ve set up an example here:

Editor:

Preview:

The data structure is set up in this way:

Genre data type:

Streaming Service data type:

Movie data type:

For example, if you created a Streaming Service thing for “Netflix”, that thing’s List of Movies would contain all of the Movie Entries that Users can watch on Netflix:

And if you created a Genre thing called “Drama”, that thing’s List of Movies field would contain all of the Movie Entries that are a Drama:

Within the Movie data type, we would also store the Genres and Streaming Services for each Movie there:

Back on the page, the filters are almost the same as what you currently have (with the Multidropdown data sources being modified to search for Genres and Streaming Services):

Genres:

Streaming Services:

Then the repeating group expression for all of the selected Streaming Services and all of the selected Genres would be:


Here we’re first telling Bubble to find all of the selected Genre’s lists of Movies, then intersect them with all of the selected Streaming Service’s lists of Movies.
By doing this, we’re asking Bubble to display all of the Movies that are the same in both lists.
The “intersects with” operator takes two lists of Things, and returns the entries that are found within both of the lists. This is needed because we want to show the Movies which are of the Genres that the User has selected, and also make sure that the Genre’s Movies are available on the Streaming Services that the User has selected.

Then, filter the Movies by making sure that each Movie’s rating is greater than the Slider Input’s Rating value, and that each Movie’s release year is within the range of the Slider Input Year range of numbers.

An example would be that here the User has selected that they want to watch a Comedy on Netflix:

Airplane! is also a Comedy within the database, but since it’s not on Netflix (only Amazon), so it isn’t shown above. If the Current User then selects Amazon, it changes the Movie results to show both Movies:

Then let’s say we add Drama as well:

This shows all of the results :slight_smile:

Last but not least! We need to add conditional statements to make sure that the repeating group displays all of the Movies when the Current User hasn’t selected any Genres, or has selected Genres without Streaming Services, or has selected Streaming Services without Genres, and sort them all by Release Date or Rating.

In the first conditional on the repeating group, we’re telling Bubble “This is what the Repeating Group data source should be, if the Current User has chosen to sort the results by “Highest Rated”, and has selected at least one Genre and at least one Streaming Service from the Multidropdowns”:

There are 7 other conditional statements which change the data source depending on what has just happened on screen:
2. The Current User has chosen to sort the results by “Highest Rated”, and has selected only Streaming Services
3. The Current User has chosen to sort the results by “Highest Rated”, and has selected only Genres
4. The Current User has chosen to sort the results by “Newest Release”, and has selected Genres and Streaming Services
5. The Current User has chosen to sort the results by “Newest Release”, and has selected only Streaming Services
6. The Current User has chosen to sort the results by “Newest Release”, and has selected only Genres
7. The Current User has not chosen to sort the results and has not selected any Genres or Streaming Services, so all Movies should be displayed
8. The Current User has not chosen to sort the results by “Highest Rated” and has not selected any Genres or Streaming Services, so all Movies should be displayed

And that should do it! :slight_smile: Feel free to let me know if you have any questions!

43 Likes