# ~ (CONTAINS) operator in CQL for Confluence search

URL: https://goingstellar.ro/reference/cql/contains-operator/

The ~ operator is the CQL CONTAINS operator. It matches a field against words you give it, not against an exact string. You use it to find pages by words in the title or body, with a trailing wildcard or a quoted phrase when you need more control.

## Syntax

```
field ~ word
field ~ "word*"
field ~ "\"exact phrase\""
```

## Arguments

- `field` (optional: yes): A text field, usually title or text. Sub-fields such as creator.fullname also work.
- `value` (optional: yes): A word, a word with a trailing wildcard (*), or a phrase wrapped in escaped double quotes inside the string.

## Works with

- Operators: ~ is for text fields: title, text, and sub-fields such as creator.fullname. It also runs on space, where it matches the space name.
- Functions: none.
- Not with: fields that take ids, dates or fixed values such as id, created, type and label. Use = or IN there.

## Examples

```
title ~ "hand*"
```

Finds pages whose title has a word starting with "hand", for example a handbook. Run on Confluence Cloud on 2026-11-29.

```
text ~ "\"design notes\""
```

Searches the body of pages for the exact phrase, with the words next to each other and in that order. Run on Confluence Cloud on 2026-11-29.

```
title ~ "polic*" and space = SD
```

Lists policy pages in one space, whatever the exact title says. Run on Confluence Cloud on 2026-11-29.

```
title ~ "Remote Guidelines"
```

Finds a page when you remember two words from its title but not the order or the words between them. Run on Confluence Cloud on 2026-11-29.

```
text ~ "incident" and type = page and space = SD ORDER BY lastmodified DESC
```

Finds the pages that mention an incident, most recently changed first. Run on Confluence Cloud on 2026-11-29.

## Pitfalls

- A bare word is a whole-word match. `title ~ "hand"` does not find a title with "Handbook", while `title ~ "hand*"` does (checked on Confluence Cloud, November 2026). A wildcard at the start, as in `"*hand"`, matches nothing.
- Several words without quotes match in any order: `title ~ "Remote Guidelines"` finds "Remote Work Guidelines". With escaped quotes the words must appear together and in order, so `title ~ "\"Work Remote\""` finds nothing.
- The documentation says ~ does not work on `space`. `space ~ "Software"` runs and matches the space name (checked on Confluence Cloud, November 2026). `space ~ "SD"` finds nothing, because the key is not part of the name.
- Inner quotes must be escaped with a backslash inside the quoted value. The rules for stemming, wildcards and special characters belong to text search in general and are covered on the text search syntax page.

## Questions and answers

### Is ~ case sensitive?

No. Titles written with different capitals match the same query, for example `title ~ "Handbok~"` and `title ~ "handbok~"` both find the same page.

## Related

- [!~](https://goingstellar.ro/reference/cql/does-not-contain-operator/)
- [Text search](https://goingstellar.ro/reference/cql/text-search-syntax/)
- [text](https://goingstellar.ro/reference/cql/text-field/)
- [title](https://goingstellar.ro/reference/cql/title-field/)
- [=](https://goingstellar.ro/reference/cql/equals-operator/)
- [space](https://goingstellar.ro/reference/cql/space-field/)

## Sources

- [CQL operators (Atlassian Developer, Confluence Cloud)](https://developer.atlassian.com/cloud/confluence/cql-operators/)
- [Performing text searches using CQL (Atlassian Developer, Confluence Cloud)](https://developer.atlassian.com/cloud/confluence/performing-text-searches-using-cql/)

