as a reader this forum has been tremendous helpful. Currently, however, I struggle with an issue where I apparently fail to get the right key words to find the solution in the forum.
- I want to build a search function for an event market place based on an “Earliest Date” and a “Latest Date”
- I have a data type “Event” which itself entails a data type list of "Event Date"s
- Each “Event Date” has a start date, end date, a price, …
Challenge: I struggle to make a valit data source request to narrow down the list of "Event"s as input for a repeating group. (Error: value should be “Event Date” but right now is a list of "Event Date"s)
My failed attempt:
- I set the data source of the repeating group to "Search for ‘Events’
- I tried several ways to add a valid contraint starting with “Event_Date”
contains: e.g., Search for event date with constrains “Start Date” >= “Parameter_Start Date” and “End Date” <= “Parameter_End_Date”
- But somehow I get the issue ‘value should be “Event Date” but right now is a list of "Event Date"s’
In theory my search has x components:
- “Event entry” where the count of “Event Dates” within the desired range is >= 1
- Filters to set the desired range: (i) a filter “Event”'s “Event Dates”'s “Start Date” >= “Parameter_Start_Date” and (ii) a filter “Event”'s “Event Dates”'s “End Date” <= “Parameter_End_Date”
- However, I do not see a way that bubble let’s me to add the reference to the “Start Date”'s field of the Event Date in the constraint
PS: Sorry that I did not add screenshots but my variable names are all in German, so it may be confusing
Share screenshots because if everything you said is true then it will work. Is the data source in the repeating group? You’re trying to put the list of event dates inside a data source that takes a value rather than a list (I suspect you’re trying to put it in a group rather than repeating group)
Thanks for the quick response. Attached the screenshots.
- You see that the Repeating group is type “Event”. And that the data source is a search for “Events”.
- Then you see that the contraint seems not to be valid
*Resutling in the error.
Let me know if any other screenshots/ information are needed to help. Thanks a lot again!
Edited: Veranstaltung = “Event”. Veranstaltungstermin = “Event Date”, Datum_Bis = “End Date”, Datum_Von = “Start Date”
contains should be contains list
But you shouldn’t have a search as a search constraint.
Sorry, I have trouble implementing your advice.
I don’t think I can choose “contains list” instead of “contains”
And when I looked into the bubble documentation, it seems that “contains list” returns yes if the first list contains all the entries from the second list. I am looking to check whether there is any event date range within the search date range.
Would highly appreciate if you can try in simpler words (I just started with bubble 10 days ago).
I would recommend adding a ‘Parent Event’ field on the Event Date dataType, allowing you to easily fetch the Events by using a single search; “do a search for Event Dates’ Parent Events” instead of having to do a nested search. This is called a two-way data link (both datatypes are linked to eachother) and in this case it seems very justified.
Nested searches (a search inside of a search) are best avoided, and in your case even more so, because you are constraining on list fields. In theory, you would be able to do this by using Advanced Filters on the client side, but they are not a scalable solution and i would not recommend it for this usecase.
Thanks Nico, I implemented your solution and it works for filterting based on “Event Dates”. After adding the two-way data link it works.
However, I started to encounter a second problem. I do want to filter the Parent Events both based on attributes based on the Event Dates (which now works) and on attributes of the Event itself. One of the attributes is whether the event is allowed in a state (which I have saved as a list of states where the event is allowed).
In terms of logic, I want to apply as additional filter that only “Parent Events which have a license for the searched state (i.e., )” are shown.
This search works when I do the search based on the Event Type:
However, when I want to nest the filtering in the Event Date search, I cannot make a valid selection based on the data fields of Event.
PS: Sorry that variables are in German again:
- “Anerkennung_BL_aktiv” is a list of states in which the event is allowed.
- “Bundesland” meanst state and is a parameter provided by the user while searching.
This is where client side filtering could come in handy.
Client side filtering allows you to to add extra filters to a search.
You could add a filter like this:
Search for events date (Constrained): each item Event:unique elements:filtered(Constraint: Advanced filter This event’s states intersect with selected states: first item: is not empty
Client side filtering has its limitations. Its one of the top 3 reasons why bubble apps are considered slow; people use advanced clientside filtering on huge lists, runnning their app to the ground.
Filtering is fast on short lists but dont expect it to do well on lists of thousands of entries.
Having said that, I don’t think I would use it as stated above How big do you expect your lists of Events to be after the constrained search?
I generally try to setup my databases in a way that would preclude the need of advanced filters.
For example, I don’t think I would have set up Event_dates and Events as different dataTypes. (How many event dates does each event have?).
Or this might mean adding a field on the Event_date which actually contains the list of countries the parent event is allowed in. It would be a redundant field, but it would allow for a fully constrained search and no advanced filters, so it might be justified.
All i’m saying is that database design decisions affect how you can structure your app
Thanks for the long response and warning that I may considerbly slow down the app.
Regarding number of entries: It hopefully soon will be thousands of events (and hopefully later tens of thousands of events).
My rational for having two data types is:
(1) Users will want to have an overview of event overview when browsing events.
(2) Event dates data type does not only have the dates that are available for booking but will each have different number of available slots for booking and potentially even different prices.
(3) All other variables stay constant on event level
I will try the client side filtering (as a practice to learn the logic) but will then add the redundant list of states field into the Event_Date one. I trust your feeling that advanced searches should not be the standard.
Thanks a lot for your time!