Document toolboxDocument toolbox

Contains (has, ->)

Description

You can apply this operation either as a Filter or Create column operation:

Filter

Checks for the presence of one or more values in a given string. The filter will identify those strings containing at least one of the indicated values.

Create column

Creates a Boolean column that shows true when at least one of the indicated values is present in the given string.

This operation is case sensitive. Use the Contains - case insensitive (weakhas) operation if you need to apply this operation ignoring case.

How does it work in the search window?

Select Filter / Create column in the search window toolbar, then select the Contains operation. This operation requires at least two arguments (Value and contains). Optionally, you can add as many or also arguments as you need:

Argument

Data type

Argument

Data type

Value mandatory

string

contains mandatory

string

or also

string

If you use the Create column operation, the data type of the values in the new column is boolean (true or false).

You can also use the Is in (`in`, <-) operation to check for the presence of values in a given string, the only difference is the order of the arguments. The Is in operation requires you to first indicate the value(s) to check and then the general string (value IS IN string), and the Contains operation works the other way around (string CONTAINS value).

Example

In the demo.ecommerce.data table, we want to get only the events whose timestamp contains either 24 or 25 (or both). To do it, we will apply a Filter using the Contains operation.

The arguments needed for the filter are:

  • Value - timestamp column

  • contains - Click the pencil icon and enter 24

  • or also - Click the pencil icon and enter 25

Click Filter data and you will see the following result:

Click Create column and follow the same steps to add a new Boolean column that shows true when the values in the timestamp column contain 24 or 25 (or both).

How does it work in LINQ?

Use the operator where...  to apply the Filter operation and select... as...  to apply the Create column operation. These are the valid formats of the Contains operation:

  • string_general -> string_value
    Note that this format does not admit more than two arguments. Use the below format if you need to add several arguments.

  • has(string_general, string_value1, string_value2...)

Examples

You can copy the following LINQ script and try the above example on the demo.ecommerce.data table:

from demo.ecommerce.data where has(timestamp, "24", "25")

And this is the same example using the Create column operation:

from demo.ecommerce.data select has(timestamp, "24", "25") as has_24_or_25

You can also apply this operation using the -> operator. However, this syntax does not admit more than two arguments, so you can only add a single value to be searched in the selected string field. In the following examples, we want to detect events containing 24 in the timestamp column:

from demo.ecommerce.data where timestamp -> "24"