Using special characters in queries

In a query, special (that is, non-alphanumeric) characters either perform a particular action in specific contexts or are interpreted as a blank space character and are therefore ignored.

  • Coveo doesn’t index special characters. Therefore, you can’t search for a special character or for a term containing a special character, such as an email address containing the @ character. You can, however, search for special characters in field values using advanced field queries.

  • Although these characters aren’t free-text-searchable, they’re still displayed in item Quick views, excerpts, and summaries to ensure consistency with original documents. When an item that contains special characters reaches the processing stage of the indexing pipeline, Coveo converters ignore the special characters. Even though they’re not indexed, special characters are still stored so that item Quick views, excerpts, and summaries are displayed correctly.

Special characters

Use the following special characters in a Coveo search box to perform a special action in specific query contexts.

@ (at sign)

Indicates a field.

The term immediately following the at sign is interpreted as a field name. When the term isn’t a field name, either no results are returned or a syntax error message is displayed (see About Fields).

@filetype=doc finds all .doc files.

= (equal character)

Acts as an equal field operator.

When the equal character appears between a field name and its argument, the equal character acts as an equal sign.

When several terms follow =, they don’t need to be contiguous or in the exact order.

  • @title=(annual roadmap review) returns items containing annual or roadmap or review in their title since they’re between parentheses.
  • @title=annual roadmap review returns items containing annual in their title or roadmap or review anywhere in the item.

== (two equal characters)

Act as an exact match field operator.

When two equal characters appear between a field name and its argument, these equal signs act as an exact, contiguous, and same order match operator for the argument terms appearing between quotation marks.

@title=="annual roadmap review" returns only items with the title annual roadmap review.

<> (smaller than and greater than characters)

Act as an exclusion field operator.

When contiguous smaller than and greater than characters (<>) appear between a field name and its argument, they act as an exclusion operator for the argument term or terms appearing between quotation marks.

@title<>"roadmap review" returns items that don’t contain roadmap review in their title.

< (smaller than character)

Acts as an inferior mathematical field operator.

When the smaller than character appears between a field name and its date or numerical argument, the character acts as an inferior operator.

  • @size<50 returns items of 49 bytes or fewer.
  • @date<today returns items created or modified before today.

<= (smaller than and equal characters)

Act as an inferior or equal mathematical field operator.

When contiguous smaller than and equal characters appear between a field name and its date or numerical argument, they act as an inferior or equal operator.

  • @size<=50 returns items of 50 bytes or fewer.

  • @date<=yesterday returns items created or modified before today.

> (greater than character)

Acts as a superior mathematical field operator.

When the greater than character appears between a field name and its date or numerical argument, it acts as a superior operator.

  • @size>50 returns items of 51 bytes or more.

  • @date>yesterday returns items created or modified today.

>= (greater than and equal characters)

Act as a superior or equal mathematical field operator.

When contiguous greater than and equal characters appear between a field name and its date or numerical argument, they act as a superior or equal operator.

  • @size>=50 returns items of 50 bytes or more.

  • @date>=yesterday returns items created or modified since the beginning of yesterday.

+ (plus sign)

  • Matches the exact term.

    You can’t use wildcard characters with an exact match prefix.

    When the plus sign immediately precedes a term, only items containing the exact term are returned. In other words, the plus character disables stemming for the term it precedes.

    +search finds items containing search and not those containing terms of the same family, such as searched, searches, or searching.

  • Acts as the plus mathematical operator.

    In a @date field argument, when the plus sign appears between a date operator and a duration value, the duration value is added to the date operator.

    @date<yesterday+1d finds items created or modified yesterday or today, since 1 day is added to the date operator and also because the date operator follows the smaller than character.

# (number sign)

Matches an exact term.

While the # sign still works, it’s deprecated and has been replaced with the plus sign.

Like the plus sign, when the number sign1 immediately precedes a term, only items containing the exact term are returned (the term isn’t expanded by the stemming algorithm).

1: Also called hash or pound sign.

- (minus sign)

  • Excludes a term.

    Using the minus sign is equivalent to using the NOT operator before a term.

    When the minus sign1 (preceded with a space) immediately precedes a term, items containing the term (and same-root terms) are excluded from the search results.

    roadmap -2010 finds items containing roadmap but not containing 2010.

  • Acts as the minus mathematical operator.

    In a @date field argument, when the minus sign appears between a date operator and a duration value, the duration value is subtracted from the date operator.

    @date=now-1mo finds items that were created or modified within the day exactly a month prior, since 1 month is deducted from the date operator and also because the date operator follows an equal character.

  • Acts as a contiguity character.

    When the minus sign appears between terms, the returned items contain the term sequence in the specified order.

    annual-roadmap-review returns items that contain the term sequence and is equivalent to "annual roadmap review".

1: Also called hyphen or dash.

Contiguity characters

When the underscore (_), slash (/), backslash (\), dash (-), dot1(.), or single quotation mark (') character appears between terms, the returned items contain the term sequence in the order specified.

  • Coveo removes non-alphanumeric characters and replaces them with white spaces in the index. When you use a special character (for example, a dash) between terms in your queries, you may therefore have unexpected results if the indexed content contains other special characters (for example, a slash) between the same queried terms.
  • Using the contiguity characters is equivalent to using quotation mark delimited term sequences. For example, annual_roadmap_review or a mix of contiguity characters (for example, annual/roadmap\review) returns items that contain the term sequence ("annual roadmap review").

1: Also called point or period.

: (colon character)

  • Acts as a contiguity character.

    When the colon character appears between terms, the returned items contain the exact term sequence.

    annual:roadmap:review returns items containing the exact term sequence.

  • Acts as an equal field operator.

    When the colon character appears between a field name and its argument, the colon is equivalent to an equal sign. With the colon character, you don’t need to enter the at sign (@) before the field name.

    filetype:doc returns all .doc items.

.. (two dots)

Act as an inclusive value range.

When two dots1 separate two field values, the dots act as an inclusive range operator.

@size=1024..2048 finds items of which the size is greater or equal to 1024 bytes and smaller or equal to 2048 bytes.

1: Also called two points or periods.

Straight or curly quotation marks

Match term sequence.

You can use wildcard characters in a phrase enclosed in quotation marks.

When straight or curly quotation marks (" ", “ ”, or « ») enclose terms, they act as a contiguous term sequence or phrase match.

"annual roadmap review" returns items containing the exact term sequence.

* (asterisk character)

Acts as a wildcard operator.

By default, your query must include at least two characters before the * (see Using Wildcards in Queries).

When the asterisk character appears at the end of a term or in a term, it acts as a wildcard operator to specify a term completed by any number of any characters at the place of the asterisk character.

micro* returns items containing terms starting with micro such as Microsoft, microphone, or microprocessor.

? (question mark character)

Can optionally act as a wildcard operator.

Your Coveo administrator can enable the question mark wildcard behavior (see Coveo Querybox Component).

The question mark character wildcard behavior is disabled by default, therefore it’s ignored when included in queries. When enabled, the question mark character appearing at the end of a term or within a term acts as a wildcard operator to specify a term completed by any character at the place of the question mark.

When the wildcard behavior is enabled, gr?y returns items containing terms such as grey or gray.

() (parentheses)

Group enclosed terms for Boolean operators.

When parentheses group terms with adjacent and included Boolean operators, they create a filter.

Liz OR (project AND presentation) returns items that contain either Liz or both project and presentation.

(,) (comma between parentheses)

Act as a OR field operator.

When parentheses group space or comma-separated terms in the argument of a field, using the whole expression becomes the equivalent of using the OR operator between terms.

@language=(english, french, spanish) is the same as @language=english OR @language=french OR @language=spanish.

[] (square brackets)

  • Act as nested query delimiters.

    Square brackets are used as delimiters in a nested query. The nested query is a powerful yet complex Coveo query language feature that’s typically used by developers. In a search box, usage of brackets must respect the nested query syntax, with at least one level1. A single pair of brackets will return an Invalid syntax error.

    • With filetype:artist [[@artistid] [[@albumid] songtitle:love] genre:rock], the last nested query returns a list of artist from @artistid whose rock albums @albumid have at least one song with love in its title.
    • "[query]" returns items that contain the term query despite a single pair of brackets because of the quotation marks encompassing [query].
    • [query] returns an Invalid syntax error.
  • Act as delimiters in regular expressions.

    These brackets can be used in regular expressions when performing advanced field queries.

    @username /= "[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}" matches username field values that are in an email form.

1: Two pairs of brackets.

$ (dollar sign)

  • Invokes a query extension.

    The term immediately following the dollar sign character is interpreted as a query extension name. The invoked query extension is applied to the search results.

    $sort(criteria: 'datedescending') returns the input result set reordered following the specified criterion delineated with the colon character.

  • Indicates a Query pipeline language (QPL) object.

    The term immediately following the dollar sign character is interpreted as a QPL object. For some QPL objects, the search API replaces the $ expression with the corresponding query parameter value, and then sends it to the index. This returns results that contain the query parameter value.

    However, QPL objects such as device, os, and browser don’t have a matching query parameter and may be associated to many user-agent values for a single Coveo user. Using a $joinValues expression makes one string out of the many values returned by such QPL objects.

    • $language returns results for en when language query parameter value is en.

    • $joinValues(values: $device) returns results for desktop, pc, and windows to a Windows user.

  • Query extensions and QPL objects are typically used by advanced administrators and developers.

  • If the character string following the dollar sign isn’t a valid query extension name or a valid QPL object name, the query returns the following error message: “Something went wrong. If the problem persists, contact the administrator.”

TM (trademark symbol)

Represents the trademark symbol.

The ™ symbol is a ligature that’s expanded to tm in the index.

When the two letters TM appear at the end of a product name, they can represent the expanded form of the trademark symbol (™).

productnametm returns documents that contain either productnametm or productname™.

Ignored characters

All other special characters or previously specified characters appearing in other contexts in a query are treated as a blank space and ignored, or trigger an error message.

Examples of ignored special characters are: percent (%), question mark (?), exclamation point (!), semi-colon (;), ampersand (&), copyright (©), registered trademark (®), euro (), pound (£), yen (¥), circumflex (^), left and right braces ({}), and tilde (~).

annual&roadmap!review is equivalent to annual roadmap review.