--- 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/) with developer skills can use the [Query pipeline language (QPL)](https://docs.coveo.com/en/1449/) syntax to create more flexible [query pipeline rules](https://docs.coveo.com/en/236/). You can use code to add or edit [thesaurus rules](https://docs.coveo.com/en/3405/), [filters](https://docs.coveo.com/en/3410/), [ranking weights](https://docs.coveo.com/en/3412/), and [trigger rules](https://docs.coveo.com/en/3413/). ## Add query pipeline rules with code . 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. . On the selected pipeline page, select the tab for the type of rule that you want to code. . 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**. . 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/). .. 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/). ## Edit query pipeline rules with code . 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. . On the selected pipeline page, select the tab for the type of rule you want to edit with code. . Select the rule you want to edit, and click **More** > **Edit code**. . 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/) syntax. .. Click **Save**. ## Required privileges By default, members of the **Administrators** and **Relevance Managers** [built-in groups](https://docs.coveo.com/en/1980#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/) and how to [manage privileges](https://docs.coveo.com/en/3151/). [options="header", cols="1,2,1"] |=== | Action | Service - Domain | Required access level | View query pipeline rules a| * Organization - Organization * Search - Query pipelines | View .2+| Add and edit query pipeline rules with code a| Organization - Organization | View a| Search - Query pipelines | Edit |===