Hi there! I’m working on a StackExchange clone as practice, and I wanted to add a search function that can filter the questions on the home page by title and tags. When I set the filter by title, there is no problem; it works perfectly fine, but when I try to do the same with tags, I am stuck with this problem:
Value should be Tag (option set) but right now it’s a List of Tag (option set)s
Tags (data) is a list field. contains is comparing if your list field contains a single argument.
And you are referencing a multidropdown that stores a list of tags (even if 1 tag chosen there - it’s still a list)
To compare List vs List you can use Advanced: filtering but keep in mind that it is executed client-side (so Bubble will fetch more items including irrelevant and then the list of items will be filter in the browser).
So we use as much simple constraints in Do a search expression as we can for server-side filtering, then apply :filtered operator where at the bottom there is an Advanced: option.
Within this advanced option we make an expression like This Thing's list of values INTERSECT WITH multidropdown's value:count>0.
The second part OR multidropdown's value:count<1 is used as a replacement of “ignore empty constraints” option that is not available in advanced filtering.
Thank you. Seems like now the tag filter works. But it created another issue.
Scenario: There are 100 questions with different tags. First I use the tag filter. Now there are 25 questions. Then I use the title filter (contains keyword) to find a specific question, but it doesn’t work. I can only filter with tag OR keyword.
All constraints should be within 1 search expression.
And you should not to use Advanced for keyword search. Add constraint title contains input search by title's value right into Do a search expression:
P.S. Keep in mind that I’ve used conditional tab because as far as I remember even if advanced filtering element is empty (for example, when multidropdown is empty) - Bubble still loads extra things from DB. Not sure, as I’ve tested it long-long ago
Yeah. It seems like now Bubble doesn’t load anything from DB when the multi dropdown is empty. Because if I just use the title filter, nothing happens. When I only use the tag filter, it shows 0 results. So this last change just made things worse
First of all, I’m sorry for confusing you with setting data source in “Conditional” tab
The reason for it is that as far as I remember if advanced filter is used in dynamic expression of the data source - it will lead to client-side filtering even if the list to compare with (from you multidropdown, for example) is empty. That’s a thing to double check cause I’ve tested it long-long ago.
So you need to set up default Data Source (tab “Appearance”) like this (and don’t forget to check “ignore empty constraints” if you need your RG to show Things when 0 filters are applied):
No, but I fixed it and now it works The problem now is when I filter title with ‘under’ word (two questions contain this keyword) it doesn’t show anything
To emphasize, this operator will ignore any short, common words for the search. These short, common words are known as “stop words”, and an example of such a list (though this is more illustrative, and not the definitive list involved in Bubble’s text searches) can be found here. Operators and comparisons - Bubble Docs