The Query Fields query pipeline stage defines common Solr query parameters for the edismax query parser. If using a less-than sign (<) with DisMax, it must be escaped using a backslash. An alternative to this stage is the Additional Query Parameters stage.

Collapsing results

In Fusion 5.9.13 and up, you can configure this stage to collapse search results based on a field, such as product_id, to group all variations of each item into a single search result. This is useful for ecommerce sites where you want to show a single product with multiple SKUs or variations.
  1. Open your query pipeline.
  2. In the Query Fields stage, select the checkbox under Collapse and Expand Results.
  3. Under Grouping Field, enter the field name to group by, such as the product ID field.
  4. Save the query pipeline.
By default, variations are sorted by _score, but you can change this to any field in the index using the options under Group Sort. For additional collapse options, see the configuration reference below.

Query pipeline stage condition examples

Stages can be triggered conditionally when a script in the Condition field evaluates to true. Some examples are shown below. Run this stage only for mobile clients:
params.deviceType === "mobile"
Run this stage when debugging is enabled:
params.debug === "true"
Run this stage when the query includes a specific term:
params.q && params.q.includes("sale")
Run this stage when multiple conditions are met:
request.hasParam("fusion-user-name") && request.getFirstParam("fusion-user-name").equals("SuperUser");
!request.hasParam("isFusionPluginQuery")
The first condition checks that the request parameter “fusion-user-name” is present and has the value “SuperUser”. The second condition checks that the request parameter “isFusionPluginQuery” is not present.

Configuration

When entering configuration values in the UI, use unescaped characters, such as \t for the tab character. When entering configuration values in the API, use escaped characters, such as \\t for the tab character.