Base 'contains' doesn't catch properties unless exactly that value

What I’m trying to do

I want to be able to use bases to find notes that contain a certain text value in a property, but without having to be that exact value. It just needs to contain that text value.

A use case. I’m a farmer and have organized crops according to the time I sow them, time I plant them etc. One crop can have in its “sowing-time” property the values “1 ultimo january”, “2 february” and “3 medio march” (as a list property)

I want to be able to pull up a base with all the crops I can sow in March. If I put ‘sowing-time contains march’ then nothing comes up. If I put ‘sowing-time contains 3 march’ then all the crops come up with exactly “3 march” as one of the values in that property, but it doesn’t catch any crops with the value “3 medio march” or “3 ultimo march” etc.

Things I have tried

In dataview, I could make the databases in this way and it was a very powerful way to put values in properties and then pull up a list across slightly different values. I could decide exactly how specific I wanted to be and still include some values that were more specific than others.

I have tried putting several different variants of the same value in a group and telling base “Any of the following is true”. The downside is that I need to know beforehand exactly that all the variation are. In some cases I don’t and the whole point is to make the base plugin do that work for me.

file.properties.values().toString().contains(“march”)

string.contains() looks for substrings of the string.

list.contains() looks for whole items in the list.

To look for substrings of items in a list, you could do:

note["sowing-time"].filter(value.contains("march"))

Alternatively, you could use the toString method that Wanten showed, but you would probably want to limit your search for “march” to just sowing-time values instead of all property values. It would look like:

note["sowing-time"].toString().contains("march")
1 Like

How do I insert these codes? I tried copy pasting it into a base, but it didn’t work.

In your base interface, click Filter. In the popup, click the “Advanced filter” icon that’s to the right of the filter input box:

That toggles the filter mode so you can paste the code:

If you already did that and it still isn’t giving the results you expect, then can you describe what results you’re getting and show examples of your relevant Properties?

1 Like

This worked! I wish this was possible to program using the simple code interface, but that would be a feature request. Thanks a lot.