---
title: Code query pipeline rules
slug: '1854'
canonical_url: https://docs.coveo.com/en/1854/
collection: tune-relevance
source_format: adoc
---
# Code query pipeline rules

Coveo [organization members](https://docs.coveo.com/en/2869.md) with developer skills can use the [Query pipeline language (QPL)](https://docs.coveo.com/en/1449.md) syntax to create more flexible [query pipeline rules](https://docs.coveo.com/en/236.md).
You can use code to add or edit [thesaurus rules](https://docs.coveo.com/en/3405.md), [filters](https://docs.coveo.com/en/3410.md), [ranking weights](https://docs.coveo.com/en/3412.md), and [trigger rules](https://docs.coveo.com/en/3413.md).

## Add query pipeline rules with code

1. On the [**Query Pipelines**](https://platform.cloud.coveo.com/admin/#/orgid/search/pipelines/) ([platform-ca](https://platform-ca.cloud.coveo.com/admin/#/orgid/search/pipelines/) | [platform-eu](https://platform-eu.cloud.coveo.com/admin/#/orgid/search/pipelines/) | [platform-au](https://platform-au.cloud.coveo.com/admin/#/orgid/search/pipelines/)) page, click the query pipeline for which you want to code rules, and then click **Edit components** in the Action bar.

1. On the selected pipeline page, select the tab for the type of rule that you want to code.

1. On the selected rule subpage, do one of the following:

* If this is the first rule you're adding, click **Add rule with code**.

* If you're adding a rule to an existing list of rules, click [dots], and then click **Add rule with code**.

1. In the **Add a rule with code** dialog:

   ![Coveo | Add rule with code](https://docs.coveo.com/en/assets/images/tune-relevance/admin-create-rule-code.png)

.. Enter a rule that follows the [query pipeline language syntax](https://docs.coveo.com/en/1449.md).

.. Click **Add with code**.

   > **Note**
   >
   > If you try to use this interface to extend the Coveo query pipeline behavior (for example, by entering JavaScript code), you'll receive an error message:
   > 
   > `The definition of the statement is syntactically invalid.`

> **Tip**
>
> Validate that your new rule performs as desired by [checking the pipeline performance](https://docs.coveo.com/en/p47e0293.md).

## Edit query pipeline rules with code

1. On the [**Query Pipelines**](https://platform.cloud.coveo.com/admin/#/orgid/search/pipelines/) ([platform-ca](https://platform-ca.cloud.coveo.com/admin/#/orgid/search/pipelines/) | [platform-eu](https://platform-eu.cloud.coveo.com/admin/#/orgid/search/pipelines/) | [platform-au](https://platform-au.cloud.coveo.com/admin/#/orgid/search/pipelines/)) page, click the query pipeline for which you want to code rules, and then click **Edit components** in the Action bar.

1. On the selected pipeline page, select the tab for the type of rule you want to edit with code.

1. Select the rule you want to edit, and click **More** > **Edit code**.

1. In the **Edit a rule with code** dialog:

.. Modify your rule, ensuring it follows the [Query pipeline language (QPL)](https://docs.coveo.com/en/1449.md) syntax.

.. Click **Save**.

## Required privileges

By default, members of the **Administrators** and **Relevance Managers** [built-in groups](https://docs.coveo.com/en/1980.md#built-in-groups) can view or edit elements of the [**Query Pipelines**](https://platform.cloud.coveo.com/admin/#/orgid/search/pipelines/) ([platform-ca](https://platform-ca.cloud.coveo.com/admin/#/orgid/search/pipelines/) | [platform-eu](https://platform-eu.cloud.coveo.com/admin/#/orgid/search/pipelines/) | [platform-au](https://platform-au.cloud.coveo.com/admin/#/orgid/search/pipelines/)) page.

The following table indicates the required privileges to view or edit elements of the **Query Pipelines** page, and associated panels.
Learn more about the [Privilege reference](https://docs.coveo.com/en/1707.md) and how to [manage privileges](https://docs.coveo.com/en/3151.md).

| Action | Service | Domain | Required access level | View query pipeline rules | Organization | Organization | View |
|---|---|---|---|---|---|---|---|
| Search | Query pipelines | View |  |  |  |  |  |
| Add and edit query pipeline rules with code | Organization | Organization | View |  |  |  |  |
| Search | Query pipelines | Edit |  |  |  |  |  |
