> ## Documentation Index
> Fetch the complete documentation index at: https://doc.lucidworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Query Fields Stage

[localhost link]: http://localhost:3000/docs/5/fusion/reference/config-ref/pipeline-stages/query-stages/search-fields-query-stage

[mintlify link]: https://doc.lucidworks.com/docs/5/fusion/reference/config-ref/pipeline-stages/query-stages/search-fields-query-stage.md

[old doc.lw link]: https://doc.lucidworks.com/fusion/5.9/289.md

The Query Fields query pipeline stage defines common Solr query parameters for the [edismax query parser](https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+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](https://doc.lucidworks.com/docs/5/fusion/reference/config-ref/pipeline-stages/query-stages/set-query-params-stage.md).

> [card] Key questions to get you started
>
> Powered by Lucidworks Agent Studio

## 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.

Fields used for grouping must be of type string, int, or float.

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:

```js wrap  theme={"dark"}
params.deviceType === "mobile"
```

Run this stage when debugging is enabled:

```js wrap  theme={"dark"}
params.debug === "true"
```

Run this stage when the query includes a specific term:

```js wrap  theme={"dark"}
params.q && params.q.includes("sale")
```

Run this stage when multiple conditions are met:

```js wrap  theme={"dark"}
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

> [!TIP]
>
> 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.