In OData, if I leave the default delimiter of ', ' or ' ', no value is returned

I'm testing out the search api filtering and have a relatedTags parameter that is of type Collection(Edm.String) and when I perform the following filter:

relatedTags/any(rt:, 'Tag 3, Tag 2'))

which is equivalent to

relatedTags/any(rt: rt eq 'Tag 3' or rt eq 'Tag 2')

Only the latter will return results where the string array, relatedTags, has either of those values. If I set the delimiter to '|' or ',':

relatedTags/any(rt:, 'Tag 3|Tag 2', '|'))

will it return the same as the eq example above.

Even specifying the delimiter as ' ,' or ' ' won't return results.

relatedTags/any(rt:, 'Tag 3, Tag 2', ' ,'))

The OData language ref page has an example that is the same as what I've written in the first example:

Rooms/any(room: room/Tags/any(tag:, 'wifi, tub')))

1 answer

  • answered 2022-01-19 16:55 Bruce Johnston

    Your query is not the same as the example because the values in your comma-separated list have spaces inside them. You need to set the delimiter to just comma, not space or comma:

    relatedTags/any(rt:, 'Tag 3,Tag 2', ','))

    You will likely also need to trim whitespace around your tags in order for this to work.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum