Coveo Cloud Query Syntax Reference

The following table presents examples of the Coveo query syntax features that can help build more relevant search queries. The query syntax applies to all Coveo JavaScript search interfaces.

  • By default, the Coveo query syntax is disabled in Coveo JavaScript search interfaces. However, the query syntax may be enabled by an administrator or a developer through the enableQuerySyntax QueryBox option.

    When the Coveo query syntax is disabled:

    • The exact phrase match (keywords between quotes) still works (see Searching for a Phrase).

    • All non-alphanumeric characters in a query except for the underscore (_), apostrophe ('), asterisk (*), question mark (?), and space characters are converted into dots (.) and therefore considered as contiguity characters. In other words, these characters indicate that the words before and after them must be searched together, as a single expression.

      You search for world+trade+center. After the non-alphanumeric character conversion, your query becomes, which is equivalent to "world trade center" (see Searching for a Phrase). So, only items containing the phrase world trade center are returned in your search results. Conversely, if you search for world trade center (with regular space characters between the keywords), your search results consist of items in which world, trade, and/or center appear.

    • The ? and * wildcard characters can still be enabled independently through the enableQuestionMarks and enableWildcards QueryBox options respectively.
  • In queries, single quotes (') aren’t the handled the same way as double quotes ("). Single quotes are interpreted as any other alphanumerical character, except in general query expressions, while double quotes isolate phrases (see General Query Extensions and Searching for a Phrase).

Query syntax example Returns all items
Simple Queries
term containing term
term1 term2 containing both term1 and term2
"term1 term2 term3"1 containing exactly the phrase between double quotes [more]
'term1 term2 term3'

containing 'term1, term2, and term3'

Single quotes aren't handled the same as double quotes, i.e., single quotes are interpreted as any other alphanumerical character.

term*1 containing term or any word starting with term [more]
+term containing exactly term, not other words sharing the same root [more]
term1 OR term2 containing either term1 or term2 [more]
term1 NOT term2
term1 -term2
containing term1 but not term2 [more]
term1 NEAR:5 term2 in which term1 and term2 are no more than five terms apart [more]
Field Queries
@[fieldname] with any value in the specified field
to:"firstname lastname"
with from or to fields containing the specified name [more]
@title=term with the title field value containing term
@date=yesterday with the date field value being yesterday's date
@date=2015/01/01..2015/03/31 with the date field for a range of dates
@size<=128 with file size field value being less than 128 bytes [more]

@author==("bob jones","robert smith","rob johnson")

with the author field value being either of the enumerated values [more]

When an enumerated value contains more than one term, you must place the value between double quotes.

Advanced Field Queries

Advanced field queries work only with facet fields.

@title *= "*term1 te?m2" with the title field containing wildcard variants of the specified terms
@title='term1 term2 term3'

with the title field containing 'term1, term2, or term3'.

Single quotes aren't handled the same as double quotes, i.e., single quotes are interpreted as any other alphanumerical character.

@author ~= "name" with the author field containing a value with a fuzzy match for name  
@author %= "name" with the author field value phonetically matching name  
@syssite /= "^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$" with the syssite field containing a string matching an IP address regular expression (regex).
filetype:artist [[@artistid] [[@albumid] songtitle:love ] genre:rock ]

corresponding to an artist whose rock albums have at least one song with the word love in its title.

@title <> "Enterprise Search" with the title field defined, but not containing "Enterprise Search" [more]
JavaScript Search Only
term1 <@- +term2*=(term3) -@> term4

containing the terms but special characters within the no-syntax block (<@- and -@>) are removed [more].

General Query Extensions
term1 $q() term2

containing term1, term2, and the basic query expression [more].

This syntax is almost never used in the basic expression.

$qf(function:'dist(@latitude, @longitude, 46.8167, -71.2167)', fieldName: 'distance')

and adds a dynamic field called distance that calculates the distance between each item and the entered coordinates, in meters [more] [more].

$qre(expression:@sfaccountname=='MyCompany', modifier:'100')

and boosts items with the sfaccountname field with the MyCompany value by a value of 100 [more].

$qrf(expression:'sqrt(@sfarticleviewcount)', normalizeWeight: true)

and boosts items by the square root of the value of their sfarticleviewcount field. The boost is normalized to avoid completely overriding the index ranking [more].

$weight(name:'Adjacency', value:'7')

and changes the ranking so that term proximity (adjacency) is more important when ordering results [more].

$sort(criteria: 'datedescending')

and sorts results by date descending [more].

$fold(field:'@sysconversationsubjectid', range:'5')

and additionally loads up to 5 child items that share the same value as other results for the sysconversationsubjectid field [more].

$loadParent(parent:'@permanentid', child:'@parentid')

and additionally loads the item parents. Items are considered parent of another item when theirpermanentid field value is the same as the other item parentid field value [more].

There are some query extensions that return values instead of results and that must be used in conjunction with other queries to return results (see Standard Query Extensions).

Note 1: JavaScript Search page developers can enable or disable wildcard match (enableWildcards option) independently from the Coveo query syntax (enableQuerySyntax option) in the Querybox component (see Coveo Component Querybox). Exact phrase search is always available (see Searching for a Phrase).

Recommended Articles