Adding and Managing Query Pipeline Filters

Members of the Administrators and Relevance Managers built-in groups can use query pipeline filters to easily configure the scope for queries going through a given pipeline. The Filters tab allows you to enter hidden query expressions to be added to all queries going through the related query pipeline. While this feature permits the addition of any query syntax expression to any part of the query expression (i.e., q, aq, cq, dq, or lq), query pipeline filters are typically used to add a field-based expression to the constant query expression (cq).

A support agent authenticates on a customer service search interface. A query pipeline filter rule adds the expression NOT @source=="Marketing" to ensure that marketing items do not appear when the end-user is identified as a support agent. The cq is then always NOT @source=="Marketing" when support agents send queries.

The list of filters in a pipeline is empty by default. Filter rules are defined independently for each pipeline.

The following diagram highlights the position of Filter rules in the overall order of execution of query pipeline features.

Apply filter rules

Filters, by themselves, do not protect the security of filtered content. Never add a source with public access when it contains sensitive information and use a pipeline filter to exclude it.

In the following cases, sensitive content from a public source could be exposed:

  • A colleague not understanding the reason for the filter could modify or remove the filter.

  • Using other pipelines not having a similar filter from other search interfaces or directly from the API.

You can ensure security by enforce the search hub at the search token level (see Search Token Authentication). Moreover, search hubs defined on the client-side that are used as conditions in pipelines do not safeguard the security of your filters.

Access the “Filters” Tab of a Pipeline

  1. If not already done, log in to the Coveo Cloud platform as a member of a group with the required privileges to manage query pipeline components in the target Coveo Cloud organization.

  2. In the main menu on the left, under Search, select Query Pipelines.

  3. On the Query Pipelines page, access the query pipeline in which you find the filter rules you want to manage:

    • Double-click the pipeline.


    • Click the pipeline, and then in the Action bar, click Edit components.

  4. On the selected pipeline page, select the Filters tab.

Manage the Filters of a Query Pipeline

Members with the privilege to view query pipelines (i.e., the View all or the Custom access level on the Query Pipelines domain) can review filter rules in read-only mode (see Privilege Management and Query Pipelines Domain).

  1. Access the “Filters” tab of a pipeline.

  2. In the Filters tab, you can add a new filter rule:

    1. Access the Add a Filter Rule dialog by clicking Add Rule, and then selecting Filters rule.

    2. In the Add a Filter Rule dialog:

      1. Click the first drop-down menu, and then select the Query parameter in which the filter will be included in an AND expression: q, aq, cq, dq, or lq (see Query Parameters).

        In parentheses, you can see what each of the parameter acronyms stand for.

      2. Under Query filter, enter the hidden query expression to be included in all queries that go through the related query pipeline.

        (For cq filters only) Avoid including dynamic content in the input. Otherwise, you risk filling up the cache with useless data, which can have a negative impact on performance.

        When creating filters, specify what the pipeline should include rather than exclude (e.g., @source==(“Source 1”, “Source 2”) rather than NOT @source==(“Source 3”)) to prevent new source content or content types in your organization index from appearing in search results.

        If you only use an exclusion filter (e.g., NOT @source==(“Source 3”)), you must modify the filter expression when new content is added to your organization index (e.g., NOT @source==(“Source 3”, "Source 4")). To provide a controlled deployment of new sources into search results, use an inclusion filter (e.g., @source==(“Source 1”, “Source 2”)), which allows content to be included in an additive manner, rather than subtraction. This means content only appears in search results after the filter is updated, not immediately after indexing.

        You have three sources (Source 1, Source 2, Source 3) in your index and you want only Source 1 and Source 2 content to appear in the search results of a specific tab:

        • An exclusion filter (e.g., NOT @source==(“Source 3”)), requires you to modify the filter expression if you retrieve content from Source 4 (e.g., NOT @source==(“Source 3”, "Source 4")).

        • An inclusion filter (e.g., @source==(“Source 1”, “Source 2”)), requires no further changes even if you index Source 4 content.

        You want to remove the current case record in the search results when your agents perform a query, so you enter the following expression:


      3. Click Add Rule.

        • All changes are now effective.

        • For developers, you can also directly enter a rule that respects the Query Pipeline Language (QPL) syntax for filters (see, respectively, Query Parameters - cq and Filter - Query Pipeline Feature):

          1. In the Filters tab, click Add Rule, and then select Filters with code.

          2. In the Add a Rule With Code dialog, in the form editor box, enter a filter rule in the following form:

            If you base a filter rule on the content of one or more context keys, you should associate this rule to a condition asserting that those context keys have values. Otherwise, you risk injecting invalid content in your query expression (see the Leading Practices box in Filter - Query Pipeline Feature).

            filter [query_parameter] \expression``

            where you replace [query_parameter] with q, aq, cq, dq, or lq.

          3. Click Save.
  3. You can perform other actions on rules (see Adding and Managing Query Pipeline Rules and Rule Conditions From Tabs).

  4. On the search interface(s) for your Coveo Cloud organization, test your filter rule to ensure that it provides the desired outcome. Make adjustments when needed.

Required Privileges

The following table indicates the required privileges to view and edit elements of the Query Pipelines page and associated panels (see Privilege Management and Privilege Reference).

Action Service - Domain Required access level
View filter rules

Search - Query pipelines

Edit filter rules

Search - Query pipelines

Recommended Articles