Business rules are manually-created formulas for rewriting queries. This is the most versatile strategy for creating custom query rewrites. It supports a variety of conditions and actions to address a wide range of use cases. When you need a very specific query rewrite, this is the best strategy. Business rules are applied in the Apply Rules stage of the query pipeline. To learn how to use business rules in the Rules Editor, see Use Business Rules in the Rules Editor.
This article describes how to use the Business Rules screen in the Rules Editor.
LucidAcademyLucidworks offers free training to help you get started.The Course for Query Rewriting with Business Rules and Search Rewrites focuses on how using business rules and search rewrites gives you the opportunity to boost conversions and create better customer experiences by improving your relevancy:
Query Rewriting with Business Rules and Search RewritesPlay Button
Visit the LucidAcademy to see the full training catalog.

Facet rules

Facet menu

Facet rulesTo facet the rules list by Action, Status, Published, or Tags, click one of the facet items within the facet categories.To facet the rules list by Created Date or Expiration Date:
  1. Click the date start value. A calendar will appear. Created date start value
  2. Click a date to select the start of your facet range.
  3. Click the bottom date and select the end of your facet range.
Enter a term in the search bar to quickly facet your business rules.

Rules

Create a rule

  1. Click the Add button large button in the top-right corner of the card. Alternatively, click the Add button small button in the bottom-left corner of the card. The New Rule dialog box will appear. New rule
  2. Complete the required fields, at a minimum.
    GeneralConditionAction
    In the General column, only the Name field is required. Other fields are optional:
    • Description is an arbitrary string you can use to describe this rule.
    • Rule Group can be a user-defined group that you use to organize your rules.
    • Tags are another way to organize your rules. Tags appear as facets in the Business Rules interface, so you can filter the set of visible rules by tag.
    • Priority can be used to determine which rule should apply first if multiple rules are activated for the same request. Priority is an integer value, ranging from 1 to infinity, with the value 1 given lowest priority. If multiple rules have the same value, those rules are applied in a random order.
    • Enabled means that this rule is applied but not necessarily published. Disabling a rule helps ensure that it is not accidentally published.
    Conditions are triggers that activate the rule when they match the current date and time, query, or field values. See Rule conditions for more information.A rule can take different types of actions when the specified conditions are met. See Action types for more information. You can also create custom actions.
    Hover over the Info icon icon for more information.
  3. Once complete, click the Save button green button.

Copy a rule

  1. Hover over a rule. A row of buttons will appear on the right.
  2. Click the Copy button button. The Copy Rule dialog box will appear. Copy rule
  3. At a minimum, change the title of the rule.
  4. Once complete, click the Save button green button.

Edit a rule

  1. Hover over a rule. A row of buttons will appear on the right.
  2. Click the Edit button button. The Edit Rule dialog box appears. Edit rule
  3. Make your desired changes to the rule.
  4. Once complete, click the Save button green button.

Approve/deny rules

  1. Hover over a rule. A checkbox will appear on the left.
  2. Click the checkbox to select the rule.
  3. Repeat this process to select multiple rules. (optional)
  4. Click the Approve button to approve the selected rules, or click the Deny button to deny the rules.

Enable/disable a rule

  1. Hover over a rule. A checkbox will appear on the left.
  2. Click the checkbox to select the rule.
  3. Repeat this process to select multiple rules. (optional)
  4. Click the Enable button button to enable the selected rules, or click the Disable button button to disable the rules.

Publish a rule

  1. Hover over a rule. A checkbox will appear on the left.
  2. Click the checkbox to select the rule.
  3. Repeat this process to select multiple rules. (optional)
  4. Click the Publish selected buttonbutton to publish the selected rules.

Tag a rule

Tags are a powerful tool for organizing and publishing rules according to a keyword, such as black-friday-sale.
  1. Hover over a rule. A checkbox will appear on the left.
  2. Click the checkbox to select the rule.
  3. Repeat this process to select multiple rules. (optional)
  4. Click the Tag button button. A dialog box will appear.
  5. Enter a tag. To enter multiple tags, press Tab after writing each tag.
  6. Click the Add button large button to add the tag to the rule.
    See General Configuration Tags for information about how to use tagnames in the request URL to fire specific rules.

Delete rules

Delete a single rule

  1. Hover over a rule. A row of buttons will appear on the right.
  2. Click the Delete button small button. A confirmation box will appear.
  3. Click the Delete button large green button to confirm.

Delete multiple rules

  1. Hover over a rule. A checkbox will appear on the left.
  2. Click the checkbox to select the rule.
  3. Repeat this process to select multiple rules. (optional)
  4. Click the Delete button large red button to delete the selected rules. A confirmation box will appear.
  5. Click the Delete button large green button to confirm.

Sort rules

  1. Hover over column titles. A Arrow down icon icon will appear for some titles to indicate the rules list can be sorted by that column.
  2. Click on the title column to sort the rules.
The column that is currently sorting the rules list is indicated by an Arrow down icon or Arrow up icon icon.

Export rules

To export the rules list, simply click the Export button button. This generates a .csv file containing your rules.

Columns

Customize columns

To customize the columns:
  1. Hover over the row of column titles. A Config button button will appear on the right.
  2. Click the Config button button. The Customize Columns to Display dialog box will appear. Customize Columns to Display
  3. Click the checkboxes to select or deselect the columns you want to display.
  4. Click the Save button blue button to save your changes.

Configuration options

General

General configurations are used to characterize a rule, including its name, description, group, and more. They are also used to set a rule’s precedence, or priority over other rules. For complete details, see General Configurations.

Condition

Conditions, or triggers, define the environment necessary for the rule action to fire. Any combination of conditions (date, field value, query, and query profile) can be defined for a rule. For complete details, see Conditions.

Action

Business rule actions define what actions are taken when a rule fires. For complete details, see Actions.

Custom Rule Actions

Custom rule actions allow you to define a unique action to take when certain conditions are met. They involve three primary components: a query pipeline, a custom rule type, and a rule that is triggered by conditions defined by the user. For complete details, see Custom Rule Actions. To learn use custom rule actions with the API, see Create Custom Rule Actions with the API.
Custom rule actions allow you to define a unique action to take when certain conditions are met. They involve three primary components: a query pipeline, a custom rule type, and a rule that is triggered by conditions defined by the user.This article describes the general workflow for creating a custom rule action. The example assumes the following components are used:
ComponentName
Query pipelinecustom-rule-pipeline
Custom rule typecustom-rule-type
Rulecustom-rule-action
  1. Create a query pipeline, custom-rule-pipeline, that is used to complete the rule action.
  2. Create a custom rule type, custom-rule-type, that uses your query pipeline. Here are some important parameters to include in your POST request.
    Rule properties, included as part of the schema</code, define the values required from the user to create a rule that uses the custom rule type.
    id
    required
    A unique ID for the custom rule type. The id value must be unique across all apps in Fusion (global namespace).
    Example: custom-rule-type
    pipeline_id
    required
    The ID of the pipeline that is invoked during rule processing.
    Example: custom-rule-pipeline
    display_type
    required
    A user-friendly name for the custom rule type.
    Example: My Custom Rule
    custom_param1
    required
    The ID of the rule’s parameter. This field is used in the API but is not visible in the Rules Editor.
    Example: 1st-rule-parameter
    type
    required
    The type of user-input.
    Example: string
    title
    required
    A user-friendly name for the parameter.
    Example: Manufacturer
    description
    required
    A user-friendly description of what the field is used for. The description value is shown in the field’s tooltip in the Rules Editor.
    Example: The manufacturer of the product to which this rule applies.
    For example:
    curl -u USERNAME:PASSWORD -XPOST -H "Content-type:application/json" \
    https://EXAMPLE_COMPANY.b.lucidworks.cloud/api/apps/myFusionApp/custom-rule-types -d '{
    "id":"custom-rule-type",
    "pipeline_id":"custom-rule-pipeline",
    "display_type":"My Custom Rule",
    "schema": {
        "type" : "object",
        "properties" : {
        "custom_param1" : {
            "type" : "string",
            "title" : "Manufacturer",
            "description" : "The manufacturer of the product this rule action applies to."
        },
        "custom_param2" : {
            "type": "string",
            "title": "Type",
            "description": "The type of product this rule action applies to."
        }
        }
    }
    }'
    
  3. Verify the custom rule type was created by visiting https://EXAMPLE_COMPANY.b.lucidworks.cloud/api/apps/myFusionApp/custom-rule-types. Custom rule types are also available in the Rules Editor: Custom Rule Type in the Rules Editor
  4. Create a rule, custom-rule-action, that uses your custom rule, custom-rule-type. If you are creating the rule using the Query Rewrite API, the following image depicts which parameters are shared between the custom rule type and the rule: Custom rule type and rule parameters Note that the custom rule type id value is used for the rule’s type and custom_type fields. Remember to assign values to the custom rule properties, custom_param1 and custom_param2.
    curl -u USERNAME:PASSWORD -XPOST -H "Content-type:application/json" \
    https://EXAMPLE_COMPANY.b.lucidworks.cloud/api/apps/myFusionApp/query-rewrite/instances -d '{
      "id":"123456",
      "type":"custom-rule-type",
      "custom_type":"custom-rule-type",
      "name":"My Rule",
      "description":"A rule that uses my custom rule, custom-rule-type.",
      "search_terms":["upcoming sale"],
      "custom_param1":"ABC",
      "custom_param2":"XYZ",
      "pipeline_id":"custom-rule-pipeline",
      "display_type":"My Custom Rule"
    }'
    
  5. Verify your rule was created by checking the rule ID, 123456, with the Query Rewrite API: https://EXAMPLE_COMPANY.b.lucidworks.cloud/api/apps/myFusionApp/query-rewrite/instances/123456
  6. Test your custom rule using your normal rule development process.

Query Elevation Component

Fusion currently supports the use of the Query Elevation Component (QEC) with boost lists and filter lists. You must configure Solr in order to enable the QEC option. For instructions about using the QEC, see Use the Query Elevation Component.
Fusion currently supports the use of the Query Elevation Component (QEC) with boost lists and filter lists. You must configure Solr in order to enable the QEC option.
Although it will not be accessed for the elevation process, Fusion requires an independent elevate.xml file for the use of built-in rule actions with QEC due to a known issue in Solr.
  1. Create an XML file named elevate.xml in the same directory as the solrconfig.xml file.
  2. Use the following as the contents of the elevate.xml file:
    <?xml version="1.0" encoding="UTF-8" ?>
    <elevate>
    </elevate>
    
  3. In the solrconfig.xml file, add the following in the elevator search Component (searchComponent name="elevator"). Before adding, check to see if the searchComponent already exists within the file.
      <searchComponent name="elevator" class="solr.QueryElevationComponent" >
        <str name="config-file">elevate.xml</str>
      </searchComponent>
    
  4. Add elevator as a ‘last component’ part of the select handler in the solrconfig.xml file. If a last-components array is not already defined, create it at the end of the select handler’s configuration. If one is already defined, add <str>elevator</str>.
      <requestHandler name="/elevate" class="solr.SearchHandler">
        <arr name="last-components">
          <str>elevator</str>
        </arr>
      </requestHandler>
    
  5. When you create a new business rule, check the USE QUERY ELEVATION COMPONENT checkbox to use elevation. rules-qec
The Query Elevation Component only elevates documents within the query rewriting rules engine by the document id field. Ensure id is entered in the “FIELD NAME” option.

Additional details

Query pipeline stages for rules

These stages are part of the default query pipeline: Rules query stages in the query pipeline
To trigger a rule that contains a tag, specify the tagname in the request URL of the user search app. See Easily define triggers in tags for more information.
  • Modify Response with Rules
    Most rules operate on the request, but some rule types, such as banner rules or redirect rules, do their work when the response comes back. The Modify Response with Rules stage applies those rules to the response. For example, a banner rule can add a banner URL to the response before returning it to the client.
Generally, if you are using rules, you need both of these stages enabled in your query pipeline. The Apply Rules stage must come before the Solr Query stage, while the Modify Response with Rules stage must come after the Solr Query stage. Disabling or removing the Apply Rules stage will disable rules entirely. Disabling or removing the Modify Response with Rules stage will disable only the rules that perform response rewriting, if any.

Rules on response signals

Response signals capture a list of rule IDs that match the query in a multi-valued field named rule_ss.

Rules and experiments

The easiest way to integrate rules and experiments is to create one query pipeline with rules enabled and one without. Keep all other settings constant between the two pipelines. The pipeline without rules enabled must be configured manually. To create an experimental rule, use tags on the rule and set the tag in one of the variant pipelines.

FAQ

What are arbitrary values? Arbitrary values are values that are not actively used by Fusion. Instead, they are used by the user or the search application. For example, the Description is considered an arbitrary value, as it serves only to inform the user what the business rule is used for.

Additional resources

LucidAcademyLucidworks offers free training to help you get started.The Course for Query Rewriting with Business Rules and Search Rewrites focuses on how using business rules and search rewrites gives you the opportunity to boost conversions and create better customer experiences by improving your relevancy:
Query Rewriting with Business Rules and Search RewritesPlay Button
Visit the LucidAcademy to see the full training catalog.