Support Menu

Interface IQuery

Interface IQuery

The IQuery interface describes a query that can be performed on the Coveo REST Search API.

For basic usage, see the IQuery.q and properties.

In a normal scenario, a query is built by the QueryBuilder class.



Optional actionsHistory

actionsHistory: string

The actions history represents the past actions a user made and is used by the Coveo Machine Learning service to suggest recommendations. It is generated by the page view script (

Optional aq

aq: string

The advanced query expression.
This is the part of the query expression generated by code based on various rules.
eg: Selecting a facet value will cause an expression to be added to the advanced query expression.

Optional childField

childField: string

Specifies the childField when doing parent-child loading (See : Folding)

Optional context

context: object

The context is a map of key_value that can be used in the Query pipeline in the Coveo platform.

Type declaration

  • [name: string]: any

Optional cq

cq: string

The constant query expression.
This part of the expression is much alike the advanced query expression, but it is meant to hold expressions that are constant for all users of a search interface/widget.
The results of evaluating those expressions are kept in a special index cache, to avoid re-evaluating them on each query.
You must be careful to not include dynamic parts in this expression, otherwise you risk filling up the cache with useless data and this might have a negative impact on performance.
Expressions other than cq also benefit from caching in the index, but using cq allows to explicitly require that a part of the query be included in the cache.

Optional debug

debug: boolean

Setting this property to true will return more debugging information from both the index and the search API. Use this with care as this will negatively impact the performance of the query.

It should probably never be set to true in production mode...

Optional dq

dq: string

The disjunction query expression.
This is the disjunctive part of the query expression that is merged with the other expression parts using an OR boolean operator.
When specified, the final expression evaluated by the index ends up being (q aq cq) OR (dq).

Optional enableCollaborativeRating

enableCollaborativeRating: boolean

Whether the index should take collaborative rating in account when ranking result. See : ResultRating

Optional enableDidYouMean

enableDidYouMean: boolean

This enables the query correction feature of the index.
By activating this, the index returns an array of {link IQueryCorrection} with suggested word corrections.

Optional enableQuerySyntax

enableQuerySyntax: boolean

Whether to enable the special query syntax such as field references for the basic query expression (parameter q). It is equivalent to a No syntax block applied to the basic query expression. If not specified, the parameter defaults to false

Optional excerptLength

excerptLength: number

This specifies the length (in number of characters) of the excerpts generated by the indexer based on the keywords present in the query.
The index includes the top most interesting sentences (in the order they appear in the item) that fit in the specified number of characters.
When not specified, the default value is 200.

Optional fieldsToExclude

fieldsToExclude: string[]

This specifies an array of fields that should be excluded from the query results.
eg: ['@foo','@bar']

Optional fieldsToInclude

fieldsToInclude: string[]

This specifies an array of fields that should be returned for each result.
eg: ['@foo','@bar']

Optional filterField

filterField: string

This specifies a field on which Folding should be performed.
Folding is a kind of duplicate filtering where only the first result with any given value of the field is included in the result set.
It's typically used to return only one result in a conversation, for example when forum posts in a thread are indexed as separate items.

Optional filterFieldRange

filterFieldRange: number

Number of results that should be folded, using the IQuery.filterField

Optional firstResult

firstResult: number

This is the 0-based index of the first result to return.
If not specified, this parameter defaults to 0.

Optional groupBy

groupBy: IGroupByRequest[]

This specifies an array of Group By operations that can be performed on the query results to extract facets

Optional lowercaseOperators

lowercaseOperators: boolean

Whether to enable the support for operator in lowercase (AND OR -> and or)

Optional lq

lq: string

The contextual text.
This is the contextual text part of the query. It uses the Coveo Machine Learning service to pick key keywords from the text and add them to the basic expression. This field is mainly used to pass context such a case description, long textual query or any other form of text that might help in refining the query.

Optional maximumAge

maximumAge: number

The maximum age for cached query results, in milliseconds.
If results for the exact same request (including user identities) are available in the in-memory cache, they will be used if they are not older than the specified value.
Otherwise, the query will be sent to the index.

Optional numberOfResults

numberOfResults: number

This is the number of results to return, starting from IQuery.firstResult.
If not specified, this parameter defaults to 10.

Optional parentField

parentField: string

Specifies the parentField when doing parent-child loading (See : Folding)

Optional partialMatch

partialMatch: boolean

Whether to enable partial matching of the basic expression keywords.
By activating this, when the basic expression contains at least IQuery.partialMatchKeywords, items containing only the number of keywords specified by IQuery.partialMatchThreshold will also match the query.
Without this option, items are required to contain all the keywords in order to match the query.
If not specified, this parameter defaults to false.

Optional partialMatchKeywords

partialMatchKeywords: number

The minimum number of keywords needed to activate partial match.
This specifies the minimum number of keywords needed for the partial match feature to activate.
If the basic expression contains less than this number of keywords, no transformation is applied on the query.
If not specified, this parameter defaults to 5.

Optional partialMatchThreshold

partialMatchThreshold: string

The threshold to use for matching items when partial match is enabled.
This specifies the minimum number of query keywords that an item must contain when partial match is enabled. This value can either be an absolute number or a percentage value based on the total number of keywords.
If not specified, this parameter defaults to 50%.

Optional pipeline

pipeline: string

Name of the query pipeline to use.
This specifies the name of the query pipeline to use for the query. If not specified, the default value is default, which means the default query pipeline will be used.


q: string

The basic query expression.
This is typically the query expression entered by the user in a query box.
Since this part of the query is expected to come from user input, it is processed by the Did You Mean feature.

Optional queryFunctions

queryFunctions: IQueryFunction[]

This specifies an array of Query Function operation that will be executed on the results.

Optional questionMark

questionMark: boolean

Whether to enable question marks with wildcards.
This enables using the question mark ? character within wildcard expressions.

Optional rankingFunctions

rankingFunctions: IRankingFunction[]

This specifies an array of Ranking Function operations that will be executed on the result

Optional recommendation

recommendation: string

This is the id of the recommendation interface that generated the query.

Optional retrieveFirstSentences

retrieveFirstSentences: boolean

This specifies whether the first sentences of the item should be included in the results.
The retrieveFirstSentences option is typically used instead of excerpts when displaying email items, where the first sentence of the email might be of more interest than a contextually generated excerpt.

Optional searchHub

searchHub: string

The hub value set from the Analytics component.
Used for analytics reporting in the Coveo platform

Optional sortCriteria

sortCriteria: string

This specifies the sort criterion(s) to use to sort results. If not specified, this parameter defaults to Relevancy.
Possible values are :
-- relevancy : This uses all the configured ranking weights as well as any specified ranking expressions to rank results.
-- dateascending / datedescending : Sort using the value of the @date field, which is typically the last modification date of an item in the index.
-- qre : Sort using only the weights applied through ranking expressions. This is much like using Relevancy except that automatic weights based on keyword proximity etc, are not computed.
-- nosort : Do not sort the results. The order in which items are returned is essentially random.
-- @field ascending / @field descending : Sort using the value of a custom field.

Optional tab

tab: string

The tab value set from the Tab component.

Optional wildcards

wildcards: boolean

Whether to enable wildcards on the basic expression keywords.
This enables the wildcard features of the index. Coveo Platform will expand keywords containing wildcard characters to the possible matching keywords to broaden the query.
See :
If not specified, this parameter defaults to false.


  • IQuery