---
title: Text match operator (~)
description: Use the DataPrime `~` operator to match free text in a known field, or `~~` to search all fields, and compare it with `contains()`.
url: https://coralogix.com/docs/dataprime/language-reference/text_match_operator/
product: dataengine
feature: DataPrime Language
feature_id: dataprime-language
feature_identifier: dataengine/dataprime-language
last_updated: '2026-11-04'
---

# Text match operator (\~)

The `~` operator checks whether a specified field matches a free-text pattern. It's the underlying mechanism behind the [`find` / `text`](https://coralogix.com/docs/dataprime/language-reference/commands-reference/find_text.md) command, which is a shorthand for combining `filter` with a `~` text match.

## Syntax

```
<keypath> ~ '<text>'
```

## Field-specific vs. all-fields matching

Use `~` when you know which field holds the value you're searching for:

```
source logs

| filter msg ~ 'eu-west-1a'
```

This is equivalent to:

```
source logs

| find 'eu-west-1a' in msg
```

When you don't know which field contains the value, use the all-fields variant `~~` (also available as the [`wildfind` / `wildtext`](https://coralogix.com/docs/dataprime/language-reference/commands-reference/wildfind_wildtext.md) command) instead:

```
source logs

| filter $d ~~ 'eu-west-1a'
```

`~~` is significantly slower than `~`, since it must inspect every root-level field of every document. Prefer `~` whenever the keypath is known.

## Combining with other filters

`~` can be combined with additional `filter` stages, like any other boolean expression:

```
source logs

| filter msg ~ 'timeout'

| filter $m.severity == 'Error'
```

## `~` vs. `contains()`

`~` performs a text match, not a strict substring check. For case-sensitive substring containment, use [`contains()`](https://coralogix.com/docs/dataprime/language-reference/functions-reference/string/contains.md) instead. See [`case_contains`](https://coralogix.com/docs/dataprime/language-reference/functions-reference/cases/case_contains.md) and [`case_find`](https://coralogix.com/docs/dataprime/language-reference/functions-reference/cases/case_find.md) for the equivalents inside `case` expressions.

## See also

* [`find` / `text`](https://coralogix.com/docs/dataprime/language-reference/commands-reference/find_text.md)
* [`wildfind` / `wildtext`](https://coralogix.com/docs/dataprime/language-reference/commands-reference/wildfind_wildtext.md)
* [Fuzzy search all fields](https://coralogix.com/docs/dataprime/cookbook/fuzzy_search_all_fields.md)
