QueryParamOverride: Query pipeline feature
QueryParamOverride: Query pipeline feature
A query pipeline statement expressing the queryParamOverride
query pipeline feature modifies query parameter values before the search (or Coveo Machine Learning (Coveo ML) Query Suggestion (QS)) request is processed any further by the Search API.
Leading practice
Typically, a statement expressing the In general, you should ensure that this is the case by associating such a statement, and/or the query pipeline it’s defined in, to a global condition. |
Note
In the Coveo Administration Console, you can manage statements expressing the |
The following diagram shows the process of a query being sent to the Search API and the order of execution of query pipeline features.
Syntax
Use the following query pipeline language (QPL) syntax to define a statement expressing the queryParamOverride
feature:
override <query | querySuggest> <queryParameterOverrides>
<query | querySuggest>
This is one of the two options:
-
query
: modifies parameters in search requests (that is, inGET
orPOST
requests to the/rest/search/v2
route). -
querySuggest
: modifies parameters in query suggestion requests (that is, inGET
orPOST
requests to the/rest/search/v2/querySuggest
route).
<queryParameterOverrides>
A comma-separated list of parameter-value pairs, where each parameter is a valid query/query suggestion parameter and each value must be a valid value for the specified query/query suggestion parameter (see Query parameters).
Example
You create a global condition with the following QPL definition:
Global condition:
when $context[userRole] is "powerUser"
In an empty query pipeline named Testing Override
, you create two distinct statements, each expressing the queryParamOverride
feature, with the following QPL definitions:
Statement 1
override querySuggest enableWordCompletion: true, count: 3
Statement 2
override query enableQuerySyntax: true, wildcards: true
You associate these statements to the global condition statement you created before.
In a graphical search interface, an end user types in a search box which has been configured to provide Coveo Machine Learning (Coveo ML) query completion suggestions, causing a querySuggest
request to be sent with a partial basic query expression (q
) to the Search API on each new keystroke:
querySuggest payload
{
"q": "query pip",
"context": {
"userRole": "powerUser"
}
}
Since the query suggestion operation goes through the Testing Override
query pipeline and satisfies the global condition, the querySuggest
override statement is applied.
As a result the following things happen:
-
The query suggestions are ordered by which suggestion best completes the last word being typed by the end user in the search box (because of
enableWordCompletion: true
). -
A maximum of three query completion suggestions is returned (because of
count: 3
).
Successful response - 200 OK
|
The end user ignores the query completion suggestions, and finally inputs an expression which includes a wildcard character (*
) and advanced query syntax (@source==docs.coveo.com
) before submitting the query:
Query payload
{
"context": {
"userRole": "powerUser"
},
"q": "query pip* @source==docs.coveo.com"
}
Since the query goes through the Testing Override
query pipeline and satisfies the global condition, the query
override statement is applied.
As a result the following things happen:
-
The index only return items whose
@source
field value is equal todocs.coveo.com
(because ofenableQuerySyntax: true
). -
The index only return items whose content includes both the
query
keyword and a keyword that starts withpip
(because ofwildcards: true
).