Search Prefixes and Operators

You can use search prefixes and operators to refine a search by specifying more precisely what terms (words, numbers, expressions, etc.) you’re looking for. The following sections describe the syntax of prefixes and operators that you can use when you build a search query.

Coveo doesn’t index special characters other than letters and numbers. This means that you can’t search for a special character or for an expression containing a special character such as an email address that contains the @ character. You can however use them to make your queries more specific (see Using Special Characters in Queries and Advanced Field Queries).

If you have querying issues, see Troubleshoot Querying Issues for troubleshooting guidelines.

Exact Match Operators

Exact match operators allow you to search for a specific term or phrase (see Searching for an Exact Term and Searching for a Phrase).

Boolean Operators

The following Boolean operators act on string content. You can enable them by setting the enableQuerySyntax query parameter to true.

AND

The item must contain all terms (words, numbers, etc.) joined by AND. The term order is irrelevant.

By default, the AND operator is implicitly assumed between many terms separated by a space.

Coveo AND Search AND Help Finds items containing all three terms and is equivalent to: Coveo Search Help

OR

The item must contain at least one of the terms (words, numbers, etc.) joined by OR.

Coveo OR Search Finds items containing Coveo or Search, or both.

You can also use comma-separated terms between parentheses to achieve the same results (see Miscellaneous Operators).

NOT

The item must not contain the term (words, numbers, etc.) preceded by NOT.

The - prefix has the same effect (see Miscellaneous Operators).

report NOT technical Finds items that don’t contain technical but do contain report.

NEAR

The item must contain the two terms (words, numbers, etc.) joined by the NEAR operator, and there shouldn’t be more than a certain number of terms between these terms in the item. This operator is useful to eliminate items containing scattered occurrences of two queried terms when you rather search for items containing the two terms close to each other.

You can specify the maximum number of terms to allow between your two terms using the NEAR:n operator format. If you use NEAR only, that is, you don’t specify a value for n, the default value is 10.

  • Coveo NEAR:5 Search Finds items in which Coveo and Search are no more than five terms apart.

  • Coveo NEAR Search Finds items in which Coveo and Search are no more than ten terms apart.

  • Boolean operators are always recognized as operators when they’re typed in uppercase letters.

  • Boolean operators are interpreted as operators regardless of their casing when entered in the search box.

  • The thesaurus is activated when a query contains the NEAR operator .

    For example, when the word phone is set as a synonym of smartphone in the thesaurus, a query for phone NEAR sales becomes smartphone NEAR sales.

  • Near:[value] isn’t interpreted as a field expression, meaning that searching for near: new york returns results containing near, new, and york.

Priority of Boolean Operators

When you use more than one Boolean operator in a query without parenthesis, the query is interpreted with the following Boolean operator priority:

NEAR NOT [AND] OR

where [AND] is an implicit AND when no operator is entered between two keywords.

You want to find a specific report for the tablet and phone sales outside the USA. You know the desired item contains the words tablet, phone, or smartphone within a few words from the word sales. So, to narrow down the results, you type the following query:

tablet AND phone OR smartphone NEAR sales NOT USA

Because of the Boolean operator priority rule, the query is interpreted as:

(tablet AND phone) OR ((smartphone NEAR sales) (NOT USA))

while you rather meant:

((tablet AND (phone OR smartphone)) NEAR sales) (NOT USA)

Use parenthesis because it’s a more explicit method to compose a query with many Boolean operators that translate to the expected behavior.

Date/Time Operators

The following date operators act on date and time values. You specify a duration value using the time units suffixes: seconds (s), minutes (m), hours (h), days (d), months (mo) or years (y).

now

The item must have been created or modified between now and a required duration value.

@date<=now-12h Finds items created or modified at least 12 hours ago.

today

The item must have been created or modified today or between today and an optional duration number of days.

  • @date=today Finds items created or modified today.

  • @date>=today-30d Finds items created or modified within the last month.

yesterday

The item must have been created or modified yesterday or between yesterday and an optional number of days.

  • @date=yesterday Finds items created or modified yesterday.

  • @date>yesterday-6d Finds items created or modified in the previous seven days.

Comparison Operators

Some special characters can be used as comparison operators to search the content of specific fields (see About Fields and Using Special Characters in Queries).

= (Contains)

The field must contain the terms (words, numbers, etc.) following =. When several terms follow =, they don’t need to be found contiguous or in the exact order, in the item.

Applies to string, numeric and date content.

@title=Coveo Finds items containing Coveo in their titles.

To increase query performance, the = operator should only be used when the field you’re querying against is NOT a facet field (see Improving Search Response Time - Comparison operators and Facet Option).

== (Is Exactly)

The field must contain the exact terms (words, numbers, etc.) as they appear following ==, in the exact and contiguous order. No other term can be present in the field.

Applies to string, numeric and date content.

@filetype=="Coveo Enterprise Search" Finds items with this exact title only: Coveo Enterprise Search.

To increase query performance, the == operator should only be used when the field you’re querying against IS a facet field (see Improving Search Response Time - Comparison operators and Facet Option).

<> (Excludes)

The field must be defined in the item, and must not contain the terms following the <> operator.

Applies to string, numeric and date content.

@title <> "Enterprise Search"

Finds items that have the title field defined and don’t contain Enterprise Search in their title.

< (Smaller Than)

The value contained in the field must be inferior to the value entered after <. For dates, this means older than, or before. A file size is entered in bytes.

Applies to numeric and date content.

  • @size<50 Finds items of 49 bytes or less.

  • @date<today Finds items created or modified before today.

> (Greater Than)

The value contained in the field must be superior to the value entered after >. For dates, this means more recent than, or after. File size is entered in bytes.

Applies to numeric and date content.

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

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

<= (Smaller Than or Equal to)

The value contained in the field must be inferior or equal to the value entered after <=. For dates, this means up to the time of reference. File size is entered in bytes.

Applies to numeric and date content.

  • @size<=50 Finds items of 50 bytes or less.

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

>= (Greater Than or Equal to)

The value contained in the field must be superior or equal to the value entered after >=. For dates, this means at the time of reference and after. File size is entered in bytes.

Applies to numeric and date content.

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

  • @date>=yesterday Finds items modified or created yesterday or today.

Mathematical Operators

Some special characters can be used for queries requiring a mathematical operation (see Using Special Characters in Queries).

.. (Value Range)

The value contained in the field must be in the inclusive range specified by two values separated by two dots (double points or periods). File size is entered in bytes.

Applies to numeric and date content.

@size=1024..2048 Finds items of at least 1024 bytes and not more than 2048 bytes in size.

You can specify a list of numeric ranges using the following format: @numericfield=(a..b,c..d,e..f).

For example, you want to look for items that were created during January of year 2014, 2013, and 2012. You can use the following many range field query:

@date=(2015/01/01..2015/01/31,2016/01/01..2016/01/31,2017/01/01..2017/01/31)

+ (Plus)

The duration value in seconds (s), minutes (m), hours (h), days (d), months (mo) or years (y), is added to the date operator (now, today, or yesterday).

@date<yesterday+1d Finds items that were created or modified yesterday or today.

- (Minus)

The duration value in seconds (s), minutes (m), hours (h), days (d), months (mo) or years (y), is subtracted from the date operator (now, today, or yesterday).

Applies to date content.

@date=now-1mo Finds items that were created or modified during one day exactly one month ago.

Email Operators

The following email operators act on string content. These prefixes return results only in search interfaces searching email messages.

from

The email message must be received from anyone whose name or address contains the specified term.

  • from:Liz Finds messages received from anyone whose name or address contains Liz.

  • from:"Liz Smith" Finds messages received from Liz Smith.

to

The email message must be sent to anyone whose name or address contains the specified term.

  • to:Liz Finds emails sent to anyone whose name or address contains Liz.

  • to:"Liz Smith" Finds emails sent to Liz Smith.

Wildcard Operators

Wildcard operators allow you to broaden search to match several variants of a word or a phrase (see Using Wildcards in Queries).

Miscellaneous Operators

- (Minus, Hyphen, or Dash Character)

The item must not contain the exact term preceded by the - prefix and a space. The exclusion prefix (-) is equivalent to using NOT before a term (see Boolean Operators and Using Special Characters in Queries).

Applies to string content.

report -technical

Finds items that contain report but don’t contain technical.

@field=( , ) (Parentheses and Comma With Field Queries)

The field must contain at least one of the values isolated by parentheses and separated by commas.

This is equivalent to using the OR operator between terms (see Boolean Operators and Using Special Characters in Queries).

Applies to string and date content.

  • @language=(english, french, spanish)

    Is the same as:

    @language=english OR @language=french OR @language=spanish

  • @title=("one exact phrase","another exacter phrase")

    Is the same as:

    @title="one exact phrase" OR @title="another exacter phrase"

$ (Dollar Character)

The dollar character invokes a query extension. The term immediately following the dollar sign character is interpreted as a query extension name (see Query extension language and Using Special Characters in Queries). The invoked query extension is applied to the search results.

report $sort(criteria: 'datedescending') Finds items that contain report, and sorts them by date in descending order.

The term immediately following the dollar sign character is interpreted as a query pipeline language (QPL) object (see QPL Objects). 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.

$language Returns results for en when language query parameter value is en.

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.

$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.”

( ) (Parentheses Grouping With Operators)

The item must contain the keywords and respect the filter built using parentheses to group keywords with operators. Parenthesis are useful to ensure that the desired results when using many Boolean operators in a query (see Priority of Boolean Operators and Using Special Characters in Queries).

Liz (project NEAR:5 presentation) Finds items containing the three keywords but where keywords project and presentation are no more than five terms apart.