Loading

Query rules UI

Stack 9.1.0 Serverless Elasticsearch

Use query rules to pin or exclude specific documents when queries contain specific keywords or phrases, or match specific search patterns. The Query rules UI provides a graphical interface to manage these rules without writing API calls or JSON configuration.

The UI enables you to:

  • Set keyword or numerical conditions. For a full list of options, refer to Rule criteria.
  • Pin or exclude specific documents in results
  • Organize rules into rulesets and set execution priority
  • Test rules against sample queries before publishing

The Query Rules UI provides the same functionality as the API with one key difference:

  • The UI defaults to docs for creating and editing rules. You cannot edit an id based rule that was created through the API.

For examples of how to search using query rules, refer to Search using Query Rules API.

If you prefer to use the Query Rules API, refer to Query Rules API.

For full access to the Query Rules UI, you need the following privileges:

  • Appropriate roles to access Kibana. For more information, refer to Built-in roles or Kibana privileges
  • A role with manage_search_query_rules cluster privilege
  • ALL option for Query Rules role privilege in the respective Kibana space

Go to your deployment and select Query Rules from the left navigation menu under Relevance. If the option does not appear, contact your administrator to review your privileges.

Landing page for Query Rules UI.

Use the following steps to first create a query ruleset, and then a query rule:

  1. Select Query Rules in the navigation menu under Relevance.

  2. Select Create ruleset:

    • Enter a name for the ruleset.
    • Select Create ruleset to confirm.
  3. When the rule creation section opens, select one of the following rule types:

    • Pin: Pin selected documents to the top of the search results.
    • Exclude: Exclude selected documents from the results.

    For more information on rule types, refer to Rule types.

  4. Select one or more documents for the rule to apply to.

  5. Select one of the following rule criteria:

    • Always: Apply the rule to all queries
    • Custom: Define conditions when the rule is applied.

    For a full list of options, refer to Rule criteria.

  6. Select Create rule.

  7. Select Save in the top right corner of the ruleset section.

Note

Each ruleset must contain at least one rule.

Use the following steps to delete a query ruleset:

  1. Select Query Rules in the navigation menu under Relevance.
  2. Select Delete or select it from the action menu (...).
  3. Select if the ruleset is safe to delete.
  4. Select Delete ruleset.

The following sections describe how to edit, delete, and re-order rules:

Use the following steps to edit a query rule:

  1. Select Query Rules in the navigation menu under Relevance.
  2. Select a ruleset.
  3. Select Edit from the action menu (...).
  4. Apply changes to the rule.
  5. Select Update rule to confirm your changes.
  6. Select Save in the top right corner of the ruleset section.
Important

Don't forget to save your changes, because unsaved rules are not applied.

Use the following steps to delete a query rule:

  1. Select Query Rules in the navigation menu under Relevance.
  2. Select a ruleset.
  3. Select Delete rule from the action menu (...)
  4. Select Delete rule.
  5. Select Save in the top right corner of the ruleset section.

Use the following steps to re-order query rules:

  1. Select Query Rules in the navigation menu under Relevance.
  2. Select a ruleset.
  3. Drag a rule using the handle icon (≡) on the left.
  4. Drop it in the new position.
  5. Select Save in the top right corner of the ruleset section.

To test a query ruleset, do the following:

  1. Select Query Rules in the navigation menu under Relevance.
  2. Select a ruleset.
  3. Select Test in Console.
  4. Run the query.
  5. Review results to confirm if the rule actions were applied as expected.

The following resources can help you understand query rules better:

Blogs:

Other documentation links: