Using regex for string-type filters

Introduction

When adding filters for a string-type field, there may be times when standard operators can't achieve what you need. For example, when defining multiple filter conditions, the default condition is AND - so ALL specified filters must be met for a match. But what if you need an OR condition?

For more complex filtering requirements, regex can be used.

This information applies wherever filters are available, not just the filter shape.

Regex filter example

Let's take the following payload:

[
    {
        "fruit": "apples pears grapes"
    },
    {
        "fruit": "grapes peaches raspberries"
    },
    {
        "fruit": "peaches"
    },
    {
        "fruit": "melon"
    }
]

Suppose we want to retrieve any items where the value of the fruit field contains peaches OR apples. We might be tempted to add two string-type filters in the filter shape:

However, this wouldn't return any matches because we'd be looking for any records where peaches AND apples are present. Instead, we can define one string-type filter with regex:

This will return the correct payload - i.e. any records where peaches AND apples are present:

Last updated