CMS API : filtering type instance query by multivalued attribute

Hello to all,

I am using the CMS api /cms/instances/file/{type}?filter={attribute}={value}

I need help finding the correct syntax to use for the filter when the attribute is multivalued , in my case the attribute is "receiver_s_email" and is an array - THANKS

Best Answer

  • jpluimers
    jpluimers E Community Moderator
    #2 Answer ✓

    @Med_2024 for multi value / repeating attributes you can use the syntax as : {attribute} contains ('value1', 'value2').
    Example: https://na-1-dev.api.opentext.com/cms/instances/object/cmv_mvtf?filter=mytags contains ('Blue 1', 'mix')

    This will filter instances that have the both values 'Blue 1' and 'mix' in the mytags attribute.

Answers

  • jpluimers
    jpluimers E Community Moderator
    #3 Answer ✓

    @Med_2024 for multi value / repeating attributes you can use the syntax as : {attribute} contains ('value1', 'value2').
    Example: https://na-1-dev.api.opentext.com/cms/instances/object/cmv_mvtf?filter=mytags contains ('Blue 1', 'mix')

    This will filter instances that have the both values 'Blue 1' and 'mix' in the mytags attribute.

  • Hello @jpluimers , I thought filtering with contains solved the issue , but not quite well :because what I want is to filter the instances that contains or includes the searched word

    Example: https://na-1-dev.api.opentext.com/cms/instances/object/cmv_mvtf?filter=mytags contains ('Blue 1',)

    should return all instances that includes 'Blue1' like : ('Blue 1', 'mix') ('Blue 1', 'Blue 2') ('Blue 1', 'Blue 2', mix) …

    current behaviour of the filter is returning instances with exact match only !!

  • jpluimers
    jpluimers E Community Moderator

    Here are some more examples to show how the filter behaves with contains.

    My test set is:
    "mytags": [ "Green 1", "Green 3", "mix" ],
    "mytags": [ "MV1", "MV3" ],
    "mytags": [ "mix", "Pineapple" ],
    "mytags": [ "Blue 1", "Blue 2", "mix" ],
    "mytags": [ "Green 1", "Blue 1", "mix" ],

    Using filter: ?filter=mytags contains ("Blue 1")
    Gives me:
    "mytags": [ "Blue 1", "Blue 2", "mix" ],
    "mytags": [ "Green 1", "Blue 1", "mix" ],

    Here every entry that has a tag "Blue 1" is returned.

    Using filter: ?filter=mytags contains ("Blue 1", "mix")
    Gives me:
    "mytags": [ "Blue 1", "Blue 2", "mix" ],

    Here the contains wants to match all tags given in the contains set and will match only one object.

    Using filter: ?filter=mytags contains ('Blue 1') or mytags contains ('Blue 2')
    Gives me:
    "mytags": [ "mix", "Pineapple" ],
    "mytags": [ "Blue 1", "Blue 2", "mix" ],
    "mytags": [ "Green 1", "Blue 1", "mix" ],

    This is an normal OR.

    Using filter: ?filter=mytags contains ('Blue 1') and mytags contains ('mix')
    Gives me:
    "mytags": [ "Blue 1", "Blue 2", "mix" ],
    "mytags": [ "Green 1", "Blue 1", "mix" ],

    This is a normal AND.

    Hope this helps to solve your filter.