Developer forum

Forum » CMS - Standard features » Difference between MatchAny, Contains and In

Difference between MatchAny, Contains and In

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

When building a query for a repository and adding a field of type string[], I can choose between MatchAny, Contains and In for the match. What's the difference between these? The docs just mention that they exist, not what they are used for.

Thanks!


Replies

 
Steffen Kruse Hansen Dynamicweb Employee
Steffen Kruse Hansen
Reply
This post has been marked as an answer

Hi Imar,

That's actually a really good question.

Equal:

If right side is an Array, Equal will work in the same way as MatchAll

MatchAny:

MatchAny should work like an if, where you OR all the different expressions together
E.g. Value1 == SearchValue1 OR Value1 == SearchValue2 OR Value1 == SearchValue3

MatchAll:

MatchAny should work like an if, where you AND all the different expressions together
E.g. Value1 == SearchValue1 AND Value1 == SearchValue2 AND Value1 == SearchValue3

In:
Works just like 'MatchAny', except that 'In' only support Arrays on the right side, where MatchAny also accept non-array values.

I hope it clearifies it a bit :)

Best regards,

Steffen

Votes for this answer: 1
 
Steffen Kruse Hansen Dynamicweb Employee
Steffen Kruse Hansen
Reply
This post has been marked as an answer

I just saw that you also asked about Contains, which I forgot to write about:

Contains:

Contains should work kind of like MatchAll except that it instead of looking for exact match, when it will look for a partial match. If we try to translate it to SQL, it would look something like this: 
Value1 LIKE 'SearchValue1%' AND Value1 = 'SearchValue2%' AND Value1 = 'SearchValue3%'
ContainsExtended:

ContainsExtended works almost like Contains, except that we have a wildcard in both the begining and end of the SearchValue. If we try to translate it to SQL, it would look something like this: 
Value1 LIKE '%SearchValue1%' AND Value1 = '%SearchValue2%' AND Value1 = '%SearchValue3%'

 

Best regards,

Steffen

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Excellent, thanks. That helps a lot. Would be good to have that in the docs somewhere!

 
Dynamicweb Employee
Carsten Boll
Reply
This post has been marked as an answer

Your wish is my command.

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Perfect, thank you!

 

You must be logged in to post in the forum