Search prefixes and operators
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.
Note
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 If you have querying issues, see the troubleshooting guidelines. |
Exact match operators
Exact match operators allow you to search for a specific term or 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.
Note
By default, the |
For example, Coveo AND Search AND Help
returns 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
.
For example, Coveo OR Search
returns items containing Coveo or Search, or both.
Alternatively, you can use comma-separated terms between parentheses to achieve the same result.
NOT
The item must not contain the term (words, numbers, etc.) preceded by NOT
.
For example, report NOT technical
returns items that don’t contain technical but do contain report.
The -
prefix has the same effect.
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.
For example, Coveo NEAR:5 Search
returns items in which Coveo and Search are no more than five terms apart.
Coveo NEAR Search
returns items in which Coveo and Search are no more than ten terms apart.
Notes
|
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
-
The implicit
AND
when no operator is entered between two keywords -
OR
For example, 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))
.
Leading practice
Use parenthesis because it’s a more explicit method to compose a query with many Boolean operators that translate to the expected behavior. However, parenthesis expressions aren’t supported immediately before or after the |
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.
For example, @date<=now-12h
returns 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.
For example, @date=today
returns items created or modified today.
@date>=today-30d
returns 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.
For example, @date=yesterday
returns items created or modified yesterday.
@date>yesterday-6d
returns 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.
=
(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.
For example, @title=Coveo
returns items containing Coveo in their titles.
Leading practice
To increase query performance, the |
==
(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.
For example, @filetype=="Coveo Enterprise Search"
returns items with this exact title only: Coveo Enterprise Search.
Leading practice
To increase query performance, the |
<>
(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.
For example, @title <> "Enterprise Search"
returns 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.
For example, @size<50
returns items of 49 bytes or less.
@date<today
returns 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.
For example, @size>50
returns items of 51 bytes or more.
@date>yesterday
returns 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.
For example, @size<=50
returns items of 50 bytes or less.
@date<=yesterday
returns 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.
For example, @size>=50
returns items of 50 bytes or more.
@date>=yesterday
returns items modified or created yesterday or today.
Mathematical operators
Some special characters can be used for queries requiring a mathematical operation.
..
(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.
For example, @size=1024..2048
returns items of at least 1024 bytes and not more than 2048 bytes in size.
+
(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
).
For example, @date<yesterday+1d
returns 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.
For example, @date=now-1mo
returns 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.
For example, from:Liz
returns messages received from anyone whose name or address contains Liz.
from:"Liz Smith"
returns messages received from Liz Smith.
to
The email message must be sent to anyone whose name or address contains the specified term.
For example, to:Liz
returns emails sent to anyone whose name or address contains Liz.
to:"Liz Smith"
returns emails sent to Liz Smith.
Wildcard operators
Wildcard operators allow you to broaden search to match several variants of a word or a phrase.
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 for more information.
Applies to string content.
For example, report -technical
returns 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 for more information.
Applies to string and date content.
For example, @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 The invoked query extension is applied to the search results. See Query extension language and Using special characters in queries for more information.
For example, report $sort(criteria: 'datedescending')
returns 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.
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.
For example, $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.
For example, $joinValues(values: $device)
returns results for desktop
, pc
and windows
to a Windows user.
Notes
|
( )
(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 for more information.
For example, Liz (project NEAR:5 presentation)
returns items containing the three keywords but where keywords project and presentation are no more than five terms apart.