Breyta

Deila með


CONTAINS (NoSQL query)

APPLIES TO: NoSQL

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

Syntax

CONTAINS(<string_expr_1>, <string_expr_2> [, <bool_expr>])  

Arguments

Description
string_expr_1 The first string to search.
string_expr_2 The second string to find.
bool_expr (Optional) Optional boolean value for ignoring case. When set to true, CONTAINS performs a case-insensitive search. When unspecified, this value defaults to false.

Return types

Returns a boolean expression.

Examples

The following example checks if various static substrings exist in a string.

SELECT VALUE {
    containsPrefix: CONTAINS("AdventureWorks", "Adventure"), 
    containsSuffix: CONTAINS("AdventureWorks", "Works"),
    containsWrongCase: CONTAINS("AdventureWorks", "adventure"), 
    containsWrongCaseValidateCase: CONTAINS("AdventureWorks", "adventure", false), 
    containsWrongCaseIgnoreCase: CONTAINS("AdventureWorks", "works", true),
    containsMismatch: CONTAINS("AdventureWorks", "Contoso")
}
[
  {
    "containsPrefix": true,
    "containsSuffix": true,
    "containsWrongCase": false,
    "containsWrongCaseValidateCase": false,
    "containsWrongCaseIgnoreCase": true,
    "containsMismatch": false
  }
]

Remarks

  • This function performs a full scan.