CONTAINS (Azure Cosmos DB)

APPLIES TO: NoSQL

Returns a Boolean indicating whether the first string expression contains the second.

Syntax

CONTAINS(<str_expr1>, <str_expr2> [, <bool_expr>])  

Arguments

str_expr1
Is the string expression to be searched.

str_expr2
Is the string expression to find.

bool_expr Optional value for ignoring case. When set to true, CONTAINS will do a case-insensitive search. When unspecified, this value is false.

Return types

Returns a Boolean expression.

Examples

The following example checks if "abc" contains "ab" and if "abc" contains "A".

SELECT CONTAINS("abc", "ab", false) AS c1, CONTAINS("abc", "A", false) AS c2, CONTAINS("abc", "A", true) AS c3

Here is the result set.

[
    {
        "c1": true,
        "c2": false,
        "c3": true
    }
]

Remarks

Learn about how this string system function uses the index.

Next steps