Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Operator: Contains (~)

Description

The contains operator allows you to see if a text field contains a piece of text.

The text can either be an unquoted single value, or a quoted value (in either double or single quotes) - normally you would use quotes around the string to make it clear you are searching for text.

The contains value supports the Lucene Query parser syntax as documented here

Text is indexed using the "Standard Analyzer" - this means that common words (stop words) such as "a", "the", "this" will not be indexed.

To return all values that don't contain some text, use the Does Not Contain (!~) Operator

Escaping

Examples

Name matching a single value:

Code Block
languagenone
Name ~ Test

Name matching either of the two words:

Code Block
languagenone
Name ~ "defect bug"

Name matching exactly:

Code Block
languagenone
Name ~ "'change password to invalid value'"

Name matching exactly, using string escaping via backslash:

Code Block
languagenone
Name ~ "\"Change password to invalid value\""

Name with single character wildcard (would match text, test etc):

Code Block
languagenone
Name ~ "te?t"  

Name matching a prefix (Lucene wildcard query):

Code Block
languagenone
Name ~ "log*"

Long-hand form of the "Contains" operator:

Code Block
languagenone
Name CONTAINS "log"

Notes

You can search across multiple text fields by using "OR":

Code Block
languagenone
Name ~ "test" OR Description ~ "test" OR PreCondition ~ "test" ...

But that's long winded - for this reason we also provide a special field "Text" which will automatically expand to search all fields that support the "Contains" operator (including custom fields).

Here is an example of it's usage to find any records where they contain the text "exception":

Code Block
languagenone
Text !~ "exception"

See the Text field for more details.