How to not filter items in a list that dont exactly match a given search parameter?

In my use case I’m filtering a list of Restaurants with FoodCategories list as a member, The filter removes all restaurants that don’t contain what is entered into the search parameter. However my issue is that if the Restaurant has two FoodCategories associated to it and a user enters just one of those two FoodCategories into their search box it does not show the restaurant. For example, if a Steak House has Burgers and Steak as it’s two Food Categories and the user searches for just Burgers then the restaurant will not appear in the search results which it needs to as Steak House has Burgers and the user would want to see that. In this situation how do I filter objects in a list that don’t include at least one food category and make it so the the users search parameter has to include every FoodCategory that a restaurant has associated to it for it to appear in the search results? Screenshots Thank you
2 answers

You can do this in Mendix, but not by filtering. If you do not want to commit your SearchParameter, you could solve it as follows:

  • Retrieve all FoodCategories from the Search helper,
  • Iterate over the FoodCategories,
  • For each FoodCategory, retrieve all its restaurants,
  • Add these restaurants to a list (which you have to create outside the loop),
  • After the loop, filter out the blacklisted restaurants.

Hi Daniel,

I have struggled with this problem myself. The core of the issue is that there is no IN operator in XPath queries. Make sure to upvote this idea


That being said, you have several options: Rene recommends using filter or java in his answer

Another option that I have used with success is to make the search parameter persistent and commit it to the DB before searching.

Then you could query all restaurants that share a category with the search parameter easily using XPath


Hope this helps,