Advanced search question

Hi I am trying to do a large search that needs to use several criteria that then displays the results in a Repeating Group. Here are two questions that I have at the moment:

a) Imagine I have a group that contains ‘Food Types’ and in that I have a number of buttons, each with a specific Food Type, and the user can select any of the buttons to be either selected or not. I want the search to include any Food Items that have Food Type equal to one of the selected Food Type buttons. I thought I could make a list of all the Food Types selected and then search based on this, but I can not see how to do this.

b) Also I need the search to allow constraints that relate to fields that are indirectly linked - e.g., the Food Items can be stocked in Shops where the Shops have opening and closing hours and locations. How do I get the search in the Repeating Group to link to these indirect fields, as well as the direct criteria such as in a)? I have found the ‘merged with’ and ‘intersect with’ but have’t got it all working yet.

Many thanks


For a) I would think you would need to do a filter: and then a contains .

At the moment it isn’t possible (at least I can’t find a way) to dynamically add to a Custom State that is a list of things (i.e. a list of Food Types). On the database you can do Add or Remove. But you can’t with a page state, so can’t currently have a temporary “list” of selected things to compare against. So I think you would need to save it on the user database and do a contains against this. That would need to be an advanced filter: I think. Either that or create a thing and add to that.

For b) this is going to be quite hard, unless you can put it in the advanced filter: ? I recently wanted to search for something very similar to “Food Types with Locations near current position” and couldn’t do it. I ended up having to create a table with “Food Type + Address” within 10 miles. Bit of a kludge but it works for now.

OK thanks. for a) I may even create a ‘Thing’ called ‘Search’ and save each search.

For b) that is a bit of a problem if we can’t do these kinds of searches easily enough. I will try to think about another way.

Yes, I hope some of the more complex searches that are “find things that have related things that match this” search comes along at some point. I have tried to work around it for now, but it would certainly really help.

OK I have tried this but I don’t seem to be on the right track.

In this database, there are the following ‘Things’:

  • ‘Shops’ - each with locations and that are members of ‘Chains’
  • ‘Chains’ - each with a list of ‘Food Items’ that are available in all the ‘Shops’ the belong to the ‘Chain’.
  • Food Items’ - each with a ‘Food Type’ and a Cost and a Rating.

I want to allow the user to search based on parameters such as cost (Max and Min), distance from their location, Food Type (Can select none, one, several, many via individual buttons), Rating. and show the results in a Repeating Group. I also want to save the searches to build up a database of user preferences to make sensible suggestions to them in the future.

Here is what I can already do:

a) Search based on simple fields relating to the Food Items such as Cost between a Max and Min (using a slider input) and return this to the Repeating Group as it is changed
b) Save a ‘Search’ (as a Thing) with cost max and min, username, time and date stamp of search using a ‘Search’ button that records the parameters.

Here is what I can not to:
c) Search in the Repeating Group using fields that link indirectly to the search parameters:

  • e.g., 1) Return Food Items such that distance between nearest relevant Shop (which is a member of a Chain) and the user’s location is less than X, and / or sorted by ascending distance
  • e.g., 2) Use buttons to select a number of ‘Food Types’ to filter in or out of the search results
    d) Link the results in the Repeating Group do a ‘Search’ Thing (that I may have just saved down when the USer pressed ‘Submit’. I can only get the Repeating Group to show the real-time results of a simple search (i.e., with no filtering on indirect fields).

It would be very helpful to get any thoughts from anyone - Nigel has already tried above and I think understands what I am getting at. Emmanuel - it would be very helpful to get your thoughts too as you know this better than anyone, and I remember you saying that the data aspect of Bubble is very flexible and can be made to do pretty much anything as long as we approach it the right way.

Many thanks


1 Like

So looking at the first questions, here are some ways to do it

a) What you want to do here is probably to merge searches. We don’t support OR in constraints yet, which is what you need I think, so what you do instead is have more than one searches and merge them (it will make sure that you don’t have doubles). This is this option You’ll find it in the dropdown that comes right after a list (or a search).

b) For that one, you can use a filter after the search (in the same dropdown) and pick ‘Advanced’ There you’ll be able to build a more complex expression to define if an item passes the filter or not. The only thing to keep in mind there is that this filter happens on the client (user’s computer), while the search happens on the server, so you should try to have as much constraints on the search as it’s more efficient, and only use the filter and advanced feature for things that require it.


I’ve got same limitations.

Wouldn’t it possible to implement a kind of “:except filter” still based on AND constraints ?
So it could be used this way :
List of thing : except (FoodType_criteria <> FoodType1 AND Criteria2 <> Choice2)

We’ll look into this when we’ll do an overhaul of our expression composer.

1 Like

I have recently re-factored my searches and data as they had got too complex with all the temporary states and derived data. A couple of things I learned that might help (or just confuse !!) …

  1. Ruthlessly denormalise. I have treated “things” as their own little world, and have put everything that they could need onto them as lists. The an instance of a thing is now very rich, it has all the related things that it has interacted with.

  2. Searching for a thing doesn’t have to START with the thing, but it needs to end with the THING. This was something that had completely passed me by until recently.

For example, I wanted a list of Users who had created locations locally (within x miles). But I couldn’t do “Show me the Users that have Locations that are within X miles…” and I couldn’t search for Locations as I wanted to pull out Users.

What I suddenly realized was that I could search for the location (and do all the conditions on the server, like within x miles) but pull back those location’s users. So, searching for one thing, but bringing back the linked thing.

So in this case, I am searching for Locations but bringing back the Creator User.

If that makes sense :smile:

1 Like

Hi all, I am still not able to find a way to search effectively using lists of Things.

For example, I need to search for Food Items that are in Shops that are within X miles of an address. I can make a List of Shops that are within the distance, but I can not return the List of Food Items that are in at least one of those Shops.

I have also tried adding a List Of Shops onto each Food Items and using that to search but also with no success.

I think the problem is Bubble doesn’t like searching in a List of Things, and also doesn’t seem able to compare two Lists and return those items that are on both lists.

Open to ideas!



Just to add to the above, I am now trying to do everything via a ‘Search’ Thing which is then set to the page. This is working quite well in general, and has the additional benefit that I will end up with a history of users’ Searches which may be useful later.

However, I am trying to set a condition where I compare a ‘List of Shops’ and only get to use contains, doesn’t contain as the options. I don’t get any Intersect, for example.

OK, so I have been finding @NigelG’s suggestion about ‘ruthlessly denormalising’ useful. However, there are still a few problems (listed at the end).

My main Things are:

  • Chain
  • Shops
  • Food Types
  • Food Items
  • Searches

‘Chain’ has been populated with:

  • List of Shops (that are members of the Chain)
  • List of Food Types (available at the Chain)
  • List of Food Items (available at the Chain)
  • other specific data e.g., Name

‘Shop’ has been populated with:

  • Chain (that it is a member of)
  • List of Food Types (available in the Shop)
  • List of Food Items (available in the Shop)
  • other specific data e.g., Address

‘Food Type’ has been populated with:

  • List of Food Items (of that Food Type)
  • List of Chains (that offer that Food Type)

‘Food Items’ has been populated with:

  • Chain (where available)
  • List of Shops (where available)
  • Food Type (of the Food Item)
  • other specific data (e.g., cost, ingredients)

Note that currently the data model assumes a few things:

  • a specific Food Item will have all the same attributes (including Cost) everywhere (i.e., in all Shops) that it is available (i.e., in the whole Chain)
  • a Food Item will be specific to the Chain
  • probably some other assumptions that I haven’t thought of yet

For now these assumptions are ok, while I get the first version of the app to work,

So, the objective of the app is to allow users to search for Food Items that meet their parameters (Food Type, cost, distance from current location). After some experimentation and useful advice from @NigelG and @emmanuel , I have created another Thing called a ‘Search’ with the parameters required, and then set the search page to the relevant ‘Search’ (this is quite powerful as it allows to update a search in real time and also to record the searches that users carry out). Then I make the Repeating Group that returns all Food Items that match the parameters of the page’s Search.

  • Food Type - this is now working well and allows the user to select any number of Food Types
  • Cost - easily done with a slider for the range
  • Location - this is not working and is causing me problems…see b) below


a) This denormalised approach needs the app to update all the fields every time anything is changed. @NigelG have you worked out a good way to do this? I am thinking of making a page that basically updates a list of all things to match all current data and running it whenever I had added to the database.

b) I am not able to get the ‘Search’ thing to work with the location approach. I have tried a number of things including:

  • i) trying to set a ‘list of Shops in Range’ on the Search (this bit works) then make the Repeating Group return only the Food Items where ‘Shops_where_available’ intersects with the Search’s ‘Shops_in_Range’ to show the Food Items that are available in those Shops. Problem - this does not allow all the features for dealing with lists that are needed, such as Intersect. It just shows 4 options - ‘Contains’, ‘Doesn’t Contain’, ‘is empty’, ‘isn’t empty’.

  • ii) Try to make the same function reside on the ‘Search’ - I tried to ‘set list’ of Food_Items_in_Range based on a search for Food Items where ‘Shops_where_available’ (which is a list of Shops on the Food Items Thing) is intersected with the list of ‘Shops_in_Range’ on the Search. Problem - However this gives the error message ‘value should be a Shop but right now it is a…’ - it doesn’t seem to expect a list to be returned here.

  • iii) Set a list of ‘Locations where available’ on each Food Item using geographic addresses. Problem - it does not allow a list of addresses on a Thing - when you try to do this on the Data page, it removes the option for a ‘list’ of this type.

This is as far as I have got. I am sure this is solvable, like everything else has been, but would appreciate some advice.

Many thanks


We don’t support list of addresses yet (it’s a bit tricky database wise), so we what you’re trying to do might not be possible here (yet).

Ok. That might rule option b)iii) (although I may try a list of Google Places).

But what about the options b)i) and b)ii)? I think it just a question of setting it up the right way with the correct logic and syntax (that has so far eluded me!).

So your issue is that the location is in the type Shop, not Food Item, right? Our search engine won’t support having constraints on sub fields (yet). So if you can have the address at the Food Item level that should work.

It that’s complex, another option is to use the filter option after the search, and then use the Advanced feature, which lets you build more complex expressions. That’s a bit slower as the check happens on the client, so try to limit the size of the list returned by the search as much as you can with other constraints.

Food Items are available in multiple locations and you have already said that we can not have a list of addresses (as a field on the Food Item). Is it possible to have a list of Google Places on the Food Items (perhaps this is easier to store as a list) then use the Google Places list for the distance (from Current Location) as a constraint?

You’re not going to be able to have a constraint on a field that is a list, our expression builder doesn’t support that yet.

1 Like

Ok. Is it something you are looking at doing? If so, when are you thinking of introducing that? I am sure there are a few of us who would be happy to test it!

Not for the super near future, that will be part of our expression composer overhaul, to add parentheses, etc. so it’s a biggish project.

ok so I will try to use the ‘filtered:Advanced’ approach.

so with the return list of food items in the repeating group, I should be able to only show those where the Food Item has at least one shop on the ‘list of Shops where available’ where the Shop’s location is within X miles of the search location?

I have tried this a couple of ways so far but got back to the problem mentioned above as b)i) - it does not give me the option to search by X miles of Location Y.

Can you help me to get this right?