--- title: About queries slug: '1199' canonical_url: https://docs.coveo.com/en/1199/ collection: coveo-for-salesforce source_format: adoc --- # About queries A _query_ usually consist of one or many expressions, which are sent to the index in order to get results. Expressions can be entered in many ways while building a query: * By means of the search box * By the configurations applied in the Interface Editor * By the filters and contextual editor in an [Insight Panel](https://docs.coveo.com/en/2898/) * By handling JavaScript Search events to alter the query Through these means, your expression finds itself in different parts of the query. Therefore, it becomes important to understand how to effectively form your request, as it influences the way your expressions are processed (see [Query parameters](https://docs.coveo.com/en/13#tag/Search-V2/operation/searchUsingPost)). ## Expression types ### Original 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's processed by the **Did You Mean** feature. [example.code] #### **Invoking the parameter** ```javascript &q="{term, field}" ``` #### [example.code] #### **Applying to a building/ongoing query** ```javascript var value = $("#search").coveo('state', 'q'); $("#search").coveo('state', 'q', 'new value'); ``` #### === Advanced expression This is the part of the query expression generated by code based on various rules, for example, the expressions generated by the use of a facet. [example.code] #### **Invoking the parameter** ```javascript &aq="{term, field}" ``` #### [example.code] #### **Applying to a building/Ongoing Query** ```text See the JavaScript Search QueryBuilder object. ``` #### === Constant expression This part of the expression is similar to the advanced query expression. However, it's 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. Be careful not to include dynamic parts in this expression. Otherwise, you risk filling the cache with useless data, which might have a negative impact on performance. [example.code] #### **Invoking the parameter** ```javascript &cq="{term, field}" ``` #### [example.code] #### **Applying to a building/Ongoing Query** ```text See the JavaScript Search QueryBuilder object. ``` #### === Large expression > **Note** > > To have this expression, you must activate [Coveo Machine Learning (Coveo ML)](https://docs.coveo.com/en/188/) [Intelligent Term Detection (ITD)](https://docs.coveo.com/en/207/) (see [Comply with Intelligent Term Detection (ITD)](https://docs.coveo.com/en/l1ca1038#comply-with-intelligent-term-detection-itd)). When Intelligent Term Detection is activated, your search context (for example, the Case subject) is sent in this expression. This allows Coveo Machine Learning to detect the most important words from the context and add it to the query. For more information, see [`lq`](https://coveo.github.io/search-ui/interfaces/iquery.html#lq). [example.code] #### **Invoking the parameter** ```javascript &lq="{term, field}" ``` #### [example.code] #### **Applying to a building/Ongoing Query** ```text See the JavaScript Search QueryBuilder object. ``` #### === Nested expression This is the disjunctive part of the query expression that's 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).` [example.code] #### **Invoking the parameter** ```javascript &dq="{term, field}" ``` #### [example.code] #### **Applying to a building/Ongoing Query** ```text See the JavaScript Search QueryBuilder object. ``` #### === Query functions This specifies an array of function operations executed on the result to restrict the matching. [example.code] #### **Invoking the parameter** ```javascript &queryFunction=[{"function":"aFct","fieldname":"aName"}] ``` #### [example.code] #### **Applying to a building/Ongoing Query** ```text See the JavaScript Search QueryBuilder object. ``` #### === Ranking expression This specifies an array of function operations executed on the result to alter their ranking. [example.code] #### **Invoking the parameter** ```javascript &rankingFunction=[{"expression":"anExp","normalizedWeight":"{True, False}"}] ``` #### [example.code] #### **Applying to a building/Ongoing Query** ```text See the JavaScript Search QueryBuilder object. ``` #### == Inspecting a query To inspect these types of expressions, your best option is to use your browser developer tools. For example, in Chrome, select F12 (Windows) or Option+Command+I (Mac). In the excerpt below, from the **Network** tab of a query originating of a SidePanel, you can clearly see in the `AdvancedExpression` (**aq**) the application of the contextual query entered from the Insight Panel editor. In this contextual part of the query, extensions are mainly being used as ranking expressions. Also entered from the **Insight Panel** editor, you can see the `ConstantExpression` (**cq**), which refers to the filters. Lastly, there are no **originalExpressions**, **rankingFunctions**, nor **queryFunctions**. image::https://docs.coveo.com/en/assets/images/{{ site.baseurl}}/assets/images/coveo-for-salesforce/attachments/27885603/28147741.png?effects=drop-shadow[Inspecting a query using the Network tab in your browser developer tools,role="bordered zoom"] Another way to inspect the query would be to look at the **Console** tab image::https://docs.coveo.com/en/assets/images/{{ site.baseurl}}/assets/images/coveo-for-salesforce/attachments/27885603/28147743.png?effects=drop-shadow[Inspecting a query using the Console tab in your browser developer tools,role="bordered zoom"]