Query items which contain at least one item from list of tags

Is it possible to query items using filters which test against partial similarity?
(in python)

for example some entities ‘Objects’ have field tags

object_1 -tags: ['square', 'metal']
object_2 -tags: ['circle' ,'rubber']
object_3 -tags: ['round','liquid']
object_4 -tags:[]

is it possible to create query which would found ‘Objects’ with at least one tag from

['metal','round']

in a single step ?

So that it would return
object_1 and object_3

Hi @tweekazoid

It is possible with
Complex filters. Unfortunately I do not have the time to create you a code example but I hope that brings you in the right direction.

Cheers Fabian

1 Like

That should help,
I will try that, but it looks like the exact thing I was after.

ok,
I;ve tried that. And it did the job
Thanks

# returns doubly excluded items
r = sg.find( element ,
    [
    # filter 1 by date
     ['updated_at', 'less_than', datetime.datetime(2022, 7, 14, 12, 38, 22, 947614, tzinfo=datetime.timezone.utc)],
    
    # filter 2 by assigned tag
     {'filter_operator': 'any',
      'filters': [['tags', 'name_contains', 'something'],
                  ['tags', 'name_contains', 'another_thing']]}
    ],
    filter_operator='all'
)

2 Likes