contains

New in Domino 11: In addition to using NSF scanning and view indexes, DQL provides the contains operator to process queries against full text indexes. A database must have a full text index to be processed in this way.

Use contains to search for text strings in a specific field or across all fields in a document.

The following two examples search for text strings in specific fields:
Sales_person contains (‘Trudi’, ‘Jack*’)
Order_description contains all (‘diagonal’, ‘brushed nickel’, ‘cap*’)
The following two examples omit field names and search for text strings across all text fields in a document:
contains ('Mercury', 'spinning wildly', 'orbit*')
contains all ('Tiger Lily', 'Pete*', 'Lost boy?')

all Use all to find only documents that contain all of the specified strings. Omit all to find documents with any of the specified strings.

wildcards Use the * (asterisk) wildcard to match multiple characters. Use the ? (question mark) wildcard to match a single character.

Wildcards must be part of a string that contains non-wildcard characters. Freestanding wildcards aren't supported. For example, the following queries are valid use of wildcards:
short_description contains (‘??????hold*’)
finds threshold and thresholding.
short_description contains (‘hold?n*’)
finds each of the following: holding, holdon, or holden.
However, the following queries have freestanding wildcards and return nothing:
short_description contains (‘*’)
short_description contains (‘hold *’) 
blank spaces Blank spaces in query terms are ignored. For example, the following queries return the same results:
short_description contains ('hold')
short_description contains (' hold   ')
dashes Dashes ‘-’ are treated like regular blank spaces that occur between two searchable “words”.

This example returns any item that both contains the word “hold” and which is followed by any word starting with an “a”; this will be the intersection of the two result sets.

short_description contains (‘hold-a*’)

This example returns any item that both contains the word “hold” and which is followed by <WILDCARD *>; but since a lone ‘*’ returns nothing, the intersection of these two result sets mean that no documents are returned.

short_description contains (‘hold-*’)
Additional information
  • It finds text values only. Numbers and timedates are not searchable.
  • It is often the fastest method of searching document contents.
  • It requires a full text index. Queries fail to compile if a database does not have a full text index.
  • contains and = are not equivalent: contains searches for a text string while = searches for the entire content of a field. For example, if a document includes the field sales_person with value ‘Trudi Ayton’, only the first of the following two queries finds it:
    sales_person contains (‘Trudi’)
    sales_person = ‘Trudi’ 

Troubleshooting contains will convert your query into a full-text syntax query in the form “([<FIELD>] contains (<VALUE>))”. This is the same full-text search API used in the client search bar and the C-API. If you are receiving unexpected results, consider testing your queries using FTSearch or the client search bar directly. See How can I refine a search query using operators? in Notes documentation.

The ‘?’ operator is a wildcard that can represent any single letter. (when attached to other letters in a word).

The ‘*’ operator is a wildcard that can represent any extension of letters. (when attached to other letters in a word).

This definition is different from the conventional understanding of wildcards.