Search constraint using 'contains' on a text field is...weird

First of all, let me start by saying I am not 100% clear on the contains constraint to begin with. The reference docs sort of explain it but there are forum posts that muddle the issue. As it stands, I have seen the contains filter to work like so on a text field that is NOT a list.

fullname contains Bill - whatever text is in the field name, each word will be treated as an individual list item and compared against “Bill”. So this would return records that have “Bill Gates”, “Wild Bill” and “Someone forgot to pay the bill” in the fullname field.

It ALSO seemed to work for multi-word strings like so

fullname contains Mary Sue - this would take the words Mary and Sue and treat them as individual items and then compare them both against every word in the fullname field. If BOTH words were contained in that field, the record gets returned. So this would return records that have “Mary Sue Smith”, “Sue Mary Brown” and even “Mary really does not like Sue”

And when I say I have seen this work this way, I mean I can reproduce it. Here is a test page I threw together. https://helpexamples.bubbleapps.io/version-test/contains_text_bug?debug_mode=true

The first repeating group shows all the items I have in a table called test filterTests. There are 13 entries. The repeating grouped labeled “Search for Version A” does a search for all records where the name field contains the text “Version A”. Click the button underneath and you can see the search code. As you can see, it totally ignore the fact that it should be finding both the word “Version” and “A”. I thought maybe it couldn’t work with spaces in the text, or that it didn’t work with single character text, but the third repeating group, labeled “Search for Version B” does the exact same search, only the contains text is “Version B” and that works fine. Again, click on the button underneath and you can see the code. Repeating group 4, labeled “Search for Version C” just shows again that a search with a space and a single text character works.

Finally, the 5th repeating group labeled “Prove Multiple Items” does a search for all records where the name field contains the text items “Gray Version Lions”. I did this to try to prove the concept that each individual word is being compared to each word in the field and that the order of the words doesn’t matter.

So where does that leave me? Either I completely am missing the point of how contains works and there is some logical reason why having the word “A” screws it all up, or there is a bug in the contains function with a search constraint.

Can anyone see something I am missing or have an explanation as to why this works this way? Or can anyone confirm it appears to be a bug?

Thanks,

Marc

Here is the editor link for those who are interested. https://bubble.io/page?type=page&name=contains_text_bug&id=helpexamples&tab=tabs-1

You are right, that is a bug as far as I can see as well.

I have added an extra list that uses an advanced filter, and that works.

So looks like the contains isn’t quite right with an “A” and I have no good explanation !

p.s. it doesn’t work with “Version A” or using a custom state either. Odd !

1 Like

This topic was automatically closed after 14 days. New replies are no longer allowed.