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.

  • The Coveo query syntax is enabled by default for all Coveo JavaScript search interfaces, but may be disabled by an administrator or a developer through the enableQuerySyntax QueryBox option. When the Coveo query syntax is disabled:

  • In queries, single quotes (') are not 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 are not 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 and ending with any characters [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
from:name
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,robert,rob)

@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 are not 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.

JavaScript Search Only
term1 <@- +term2*=(term3) -@> term4

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

No syntax blocks are typically used by administrators or developers to enclose variables to prevent the special characters they contain to inadvertently affect the query.

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 must be used in conjunction with other queries to return results (see Standard Query Extensions).

Note 1: Coveo Cloud REST Search API - January 2016  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).