> ## Documentation Index
> Fetch the complete documentation index at: https://doc.lucidworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rules Editor

export const LwTemplate = ({title = "Key questions to get you started", icon = "sparkles", cta = "Powered by Agent Studio", linkHref = "https://lucidworks.com/demo/?utm_source=docs&utm_medium=referral&utm_campaign=docs_cta_ai"}) => {
  const [isLoaded, setIsLoaded] = useState(false);
  useEffect(() => {
    const timer = setTimeout(() => {
      setIsLoaded(true);
    }, 500);
    return () => clearTimeout(timer);
  }, []);
  return <div className="lw-template-container">
      <Card title={title} icon={icon}>
        {isLoaded && <span dangerouslySetInnerHTML={{
    __html: `<lw-template id="a029c1a9-28be-427e-b0e1-5d918920246a"></lw-template
            >`
  }} />}
        <Link href={linkHref} className="agent-studio-link text-left text-gray-600 gap-2 dark:text-gray-400 text-sm font-medium flex flex-row items-center hover:text-primary dark:hover:text-primary-light group-hover:text-primary group-hover:dark:text-primary-light">Powered by Lucidworks Agent Studio</Link>
      </Card>
    </div>;
};

export const InlineImage = ({src, alt = '', height = '2em'}) => {
  return <img src={src} alt={alt} style={{
    display: 'inline',
    verticalAlign: 'start',
    height: height,
    margin: '0'
  }} />;
};

[localhost link]: http://localhost:3000/docs/5/fusion/getting-data-out/query-enhancement/rules-editor

[mintlify link]: https://doc.lucidworks.com/docs/5/fusion/getting-data-out/query-enhancement/rules-editor

[old doc.lw link]: https://doc.lucidworks.com/fusion/5.9/491

The Rules Editor allows you to view, edit, create, approve, enable, and publish rules powered by Fusion. Access the Rules Editor from the Fusion UI by navigating to **Relevance** > **Rules**:

<img src="https://mintcdn.com/lucidworks/L5PMnIeZ03zhv8Ti/assets/images/5.6/access-rules-ui-56.png?fit=max&auto=format&n=L5PMnIeZ03zhv8Ti&q=85&s=92dedfe1c55e8ee9011781f79dda72a6" alt="Access the Rules Editor" width="3101" height="1499" data-path="assets/images/5.6/access-rules-ui-56.png" />

A rule’s various states determine whether the rule is in effect for everyone using your search application:

| State         | Options                 | Description                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Status**    | *Enabled* or *Disabled* | If a rule’s status is *Enabled*, the rule is in effect. If a rule’s status is *Disabled*, the rule is not in effect.  This is only true if the rule is published, as described below.                                                                                                                                                                                                                   |
| **Review**    | *Approved* or *Denied*  | If a rule’s review state is *Approved*, and you publish the changes, the latest changes to that rule are in effect. If the state is *Denied*, and you publish the changes, the Rules Manager deletes the rule. <Warning> **Caution**<br /><br /> Unlike deleting the rule with the UI, if you delete the rule by publishing it while in a *Denied* review state, you cannot undo the action. </Warning> |
| **Published** | *Yes* or *No*           | If a rule’s published state is *Yes*, the latest changes to the rule are in effect. If the state is *No*, the latest changes are not in effect.  This also applies to changes to the rule’s status, such as disabling to rule.                                                                                                                                                                          |

For more information:

* **Use the Analytics Screen in the Rules Editor**
* **Use Business Rules in the Rules Editor**
* **Use Query Rewrites in the Rules Editor**

<AccordionGroup>
  <Accordion title="Use the Analytics Screen in the Rules Editor">
    This article describes how to use the [Analytics screen](/docs/5/fusion/getting-data-out/query-enhancement/rules-editor) in the [Rules Editor](/docs/5/fusion/getting-data-out/query-enhancement/rules-editor).

    <Note>Job configuration affects the data that displays on the dashboard. For example, the [`COLLECTION_NAME_session_rollup` job](/docs/5/fusion/reference/config-ref/jobs/aggregations/built-in-sql-aggregation-jobs) aggregates related user activity into a session signal that contains activity count, duration, and keywords (based on user search terms).</Note>

    <LwTemplate />

    ### UI elements

    #### Data date range

    * **Quick Range Selectors.** Click one of the quick range selectors to facet your data.

          <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-date.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=ba2e682955eff2420ae49b54ab786f3c" alt="Data date range selectors" width="927" height="117" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-date.png" />
    * **Calendar Selector.** Use the calendar selector to specify a start and end date and time facet for your data.

          <img style={{ width: "300px" }} src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-date-calendar.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=5452da040facd2f8ebaa38a2faa84b1f" width="559" height="618" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-date-calendar.png" />

    #### Visitor data

    * **Data Cards**

          <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-visitor-cards.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=b3f43504286aaad9934106ec26125f4c" alt="Data cards" width="2319" height="369" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-visitor-cards.png" />

      * **Site Visits.** The total number of visits.
      * **Total Searches.** The total number of searches performed.
      * **Unique Visitors.** The number of unique visitors to your site.
      * **Average Session.** The average length of time spent on your site.
    * **Data Graph.** Detailed information for the selected data card.

          <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-visitor-graph.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=f195437a3c20aeba43e26c1e4c3d7786" alt="Data graph" width="2318" height="672" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-visitor-graph.png" />

    ## View data by date range

    The Rules Editor analytics allows you to view data by a date range. To do this, you can either:

    * Click one of the date range presets:

          <img src="https://mintcdn.com/lucidworks/TTnHmbCCHl-1HFoG/assets/images/5.1/ai-rules/date-range-presets.png?fit=max&auto=format&n=TTnHmbCCHl-1HFoG&q=85&s=c9972796555f38ee83888bcb2f4c5098" alt="Date range by preset" width="1026" height="156" data-path="assets/images/5.1/ai-rules/date-range-presets.png" />
    * Click the date range details to display and select your range on the calendar that appears:

          <img src="https://mintcdn.com/lucidworks/TTnHmbCCHl-1HFoG/assets/images/5.1/ai-rules/date-range-calendar.png?fit=max&auto=format&n=TTnHmbCCHl-1HFoG&q=85&s=af256a6109a4a9f3139ea133dd2e30c0" alt="Date range by calendar" width="1220" height="876" data-path="assets/images/5.1/ai-rules/date-range-calendar.png" />

    ## View additional card details

    Click one of the analytics cards to view additional details for that card’s data.

    ## Configure Analytics cards

    1. Hover over one of the cards.
    2. Click the **Edit** button that appears:  <img className="inline-image" alt="Edit Analytics card" src="https://mintcdn.com/lucidworks/rffsSynuMpAuFk9Z/assets/images/5.3/pm-analytics-edit-card.png?fit=max&auto=format&n=rffsSynuMpAuFk9Z&q=85&s=51930e81e947945c29c2eb5cdcd1c83b" width="65" height="50" data-path="assets/images/5.3/pm-analytics-edit-card.png" />
    3. Complete the form that appears.
    4. Click the **Save** button.

    If the data is empty, check to make sure the date range includes the data you want to display.

    <img src="https://mintcdn.com/lucidworks/rffsSynuMpAuFk9Z/assets/images/5.3/pm-analytics-date-range.png?fit=max&auto=format&n=rffsSynuMpAuFk9Z&q=85&s=158a4215848ce9ec97d3685bb1826a91" alt="Analytics date range" width="783" height="123" data-path="assets/images/5.3/pm-analytics-date-range.png" />
  </Accordion>

  <Accordion title="Use Business Rules in the Rules Editor">
    This article describes how to use the [Business Rules](/docs/5/fusion/getting-data-out/query-enhancement/business-rules/overview) screen in the [Rules Editor](/docs/5/fusion/getting-data-out/query-enhancement/rules-editor).

    <Card title="Query Rewriting with Business Rules and Search Rewrites" class="note-image" href="https://academy.lucidworks.com/query-rewriting-with-business-rules-and-search-rewrites" cta="Take this course on the LucidAcademy." icon="graduation-cap" iconType="duotone">
      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.
    </Card>

    ## Facet rules

    ### Facet menu

    <img src="https://mintcdn.com/lucidworks/L5PMnIeZ03zhv8Ti/assets/images/5.6/facet-menu.png?fit=max&auto=format&n=L5PMnIeZ03zhv8Ti&q=85&s=7a220e907feef17ff297b2e8879131ed" alt="Facet rules" width="2946" height="1468" data-path="assets/images/5.6/facet-menu.png" />

    To 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.

           <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/rules-facets-date.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=8e2c03acba6766993d51cc815d830410" alt="Created date start value" style={{ width: "300px" }} width="440" height="344" data-path="assets/images/5.1/ai-rules/rules-facets-date.png" />

    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.

    ### Search

    Enter a term in the search bar to quickly facet your business rules.

    ## Rules

    ### Create a rule

    1. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/add-button-1.png" alt="Add button large" /> button in the top-right corner of the card. Alternatively, click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/add-button-2.png" alt="Add button small" /> button in the bottom-left corner of the card. The **New Rule** dialog box will appear.

           <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/new-rule.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=37992007ed2233ee6cac599ce2eb6dac" alt="New rule" width="2560" height="1344" data-path="assets/images/5.1/ai-rules/new-rule.png" />
    2. Complete the required fields, at a minimum.

       |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                  |                                                                                                                                                                                                                                                                                                        |
       | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
       | General                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | Condition                                                                                                                                                                                                                        | Action                                                                                                                                                                                                                                                                                                 |
       | In the **General** column, only the **Name** field is required. Other fields are optional: <ul><li>**Description** is an arbitrary string you can use to describe this rule.</li> <li>**Rule Group** can be a user-defined group that you use to organize your rules.</li>  <li>**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.</li> <li>**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.</li> <li>**Enabled** means that this rule is applied but not necessarily published. Disabling a rule helps ensure that it is not accidentally published.</li></ul> | Conditions are triggers that activate the rule when they match the current date and time, query, or field values. See [Rule conditions](/docs/5/fusion/getting-data-out/query-enhancement/query-rewriting) for more information. | A rule can take different types of actions when the specified conditions are met. See [Action types](/docs/5/fusion/getting-data-out/query-enhancement/query-rewriting) for more information. You can also create [custom actions](/docs/5/fusion/getting-data-out/query-enhancement/query-rewriting). |

       <Tip>Hover over the <InlineImage src="/assets/images/5.1/ai-rules/icons/info-icon.png" alt="Info icon" /> icon for more information.</Tip>
    3. Once complete, click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/save-buttong.png" alt="Save button green" /> button.

    ### Copy a rule

    1. Hover over a rule. A row of buttons will appear on the right.
    2. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/copy-button.png" alt="Copy button" /> button. The **Copy Rule** dialog box will appear.

           <img src="https://mintcdn.com/lucidworks/TTnHmbCCHl-1HFoG/assets/images/5.1/ai-rules/copy-rule.png?fit=max&auto=format&n=TTnHmbCCHl-1HFoG&q=85&s=7f1ec5c812c791b509154b2d24c1641d" alt="Copy rule" width="2560" height="1344" data-path="assets/images/5.1/ai-rules/copy-rule.png" />
    3. At a minimum, change the title of the rule.
    4. Once complete, click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/save-buttong.png" alt="Save button green" /> button.

    ### Edit a rule

    1. Hover over a rule. A row of buttons will appear on the right.
    2. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/edit-button.png" alt="Edit button" /> button. The **Edit Rule** dialog box appears.

           <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/edit-rule.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=0b22a2d898cf85092f6243e5f217d677" alt="Edit rule" width="2560" height="1344" data-path="assets/images/5.1/ai-rules/edit-rule.png" />
    3. Make your desired changes to the rule.
    4. Once complete, click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/save-buttong.png" alt="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 <InlineImage src="/assets/images/5.1/ai-rules/buttons/enable-button.png" alt="Enable button" /> button to enable the selected rules, or click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/disable-button.png" alt="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 <InlineImage src="/assets/images/5.1/ai-rules/buttons/publish-selected-button.png" alt="Publish selected button" />button 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 <InlineImage src="/assets/images/5.1/ai-rules/buttons/tag-button.png" alt="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 <InlineImage src="/assets/images/5.1/ai-rules/buttons/add-button-1.png" alt="Add button large" />  button to add the tag to the rule.

           <Note>
             See [General Configuration Tags](/docs/5/fusion/getting-data-out/query-enhancement/business-rules/general-config) for information about how to use tagnames in the request URL to fire specific rules.
           </Note>

    ### Delete rules

    #### Delete a single rule

    1. Hover over a rule. A row of buttons will appear on the right.
    2. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/delete-button-2.png" alt="Delete button small" /> button. A confirmation box will appear.
    3. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/delete-button-1g.png" alt="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 <InlineImage src="/assets/images/5.1/ai-rules/buttons/delete-button-1r.png" alt="Delete button large red" /> button to delete the selected rules. A confirmation box will appear.
    5. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/delete-button-1g.png" alt="Delete button large green" /> button to confirm.

    ### Sort rules

    1. Hover over column titles. A <InlineImage src="/assets/images/5.1/ai-rules/icons/arrow-down-icon.png" alt="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.

    <Note>The column that is currently sorting the rules list is indicated by an <InlineImage src="/assets/images/5.1/ai-rules/icons/arrow-down-icon.png" alt="Arrow down icon" /> or <InlineImage src="/assets/images/5.1/ai-rules/icons/arrow-up-icon.png" alt="Arrow up icon" /> icon.</Note>

    ### Export rules

    To export the rules list, simply click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/export-button.png" alt="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 <InlineImage src="/assets/images/5.1/ai-rules/buttons/config-button.png" alt="Config button" /> button will appear on the right.
    2. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/config-button.png" alt="Config button" /> button. The **Customize Columns to Display** dialog box will appear.

           <img src="https://mintcdn.com/lucidworks/TTnHmbCCHl-1HFoG/assets/images/5.1/ai-rules/customize-columns-br.png?fit=max&auto=format&n=TTnHmbCCHl-1HFoG&q=85&s=c835f109d3cb5d5a845a3f0a7166f9db" alt="Customize Columns to Display" width="1850" height="1085" data-path="assets/images/5.1/ai-rules/customize-columns-br.png" />
    3. Click the checkboxes to select or deselect the columns you want to display.
    4. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/save-buttonb.png" alt="Save button blue" />  button to save your changes.
  </Accordion>

  <Accordion title="Use Query Rewrites in the Rules Editor">
    This article describes how to use the Rewrites screen in the [Rules Editor](/docs/5/fusion/getting-data-out/query-enhancement/rules-editor).

    ## Query rewrite rule types

    * **Head/Tail.** Replace underperforming queries with queries that produce higher click-through rates. Query improvements always require review before they are published. Schedule the Head/Tail Analysis job to get AI-generated query improvements based on your signals collection. \
      \
      Manually created Head/Tail rewrites must provide an "Improved Query" in a format appropriate to the type of request the rewrite will be applied to.  For Legacy requests, this means a valid Solr query fit for use as the `q` parameter.  For DSL requests this means a JSON string representing the main DSL query. \
      \
      For more information, see:
      * [Underperforming Query Rewriting](/docs/5/fusion/getting-data-out/query-enhancement/underperforming-queries)
      * [Head/Tail Analysis Jobs](/docs/5/fusion/reference/config-ref/jobs/head-tail-analysis)
    * **Misspelling.** Fusion replaces misspelled query terms with their spelling corrections for better search results. Schedule the Token and Phrase Spell Correction job to get AI-generated spelling corrections based on your signals collection. For more information, see [Misspelling Detection](/docs/5/fusion/getting-data-out/query-enhancement/misspelling-detection).
    * **Phrase.** Known phrases are boosted when they appear in new queries. Schedule the Phrase Extraction job to get AI-generated phrases based on your signals collection.
      For more information, see [Phrase Detection](/docs/5/fusion/getting-data-out/query-enhancement/phrase-detection).
    * **Synonym.** Synonyms are used to expand queries so that they include all known synonyms of the query terms. To retrieve AI-generated synonyms based on your signals collection, schedule the [Synonym Detection job](/docs/5/fusion/reference/config-ref/jobs/synonym-detection).
    * **Remove Words** - Remove particular phrases from queries. Unlike other rewrites, these should be entered manually and are not generated by a job. For more information, see [Remove Words](/docs/5/fusion/getting-data-out/query-enhancement/remove-words).

    ## Facets

    ### Facet menu

    <img src="https://mintcdn.com/lucidworks/L5PMnIeZ03zhv8Ti/assets/images/5.6/facet-menu.png?fit=max&auto=format&n=L5PMnIeZ03zhv8Ti&q=85&s=7a220e907feef17ff297b2e8879131ed" alt="Facet rules" width="2946" height="1468" data-path="assets/images/5.6/facet-menu.png" />

    To facet the rules list by **Status** or **Published**, click one of the facet items within the facet categories.

    To facet the rules by **Confidence**, click and drag either slider to set the range of confidence you would like to see:

    <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/rules-facet-confidence.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=52f5364289ced44dda00fa72975c48fa" alt="Confidence facet" style={{ width: "300px" }} width="436" height="194" data-path="assets/images/5.1/ai-rules/rules-facet-confidence.png" />

    <Note>Faceting rules by confidence is not available for Head/Tail rewrites.</Note>

    ### Search

    Enter a term in the search bar to quickly facet your query rewrite rules.

    ## Rules

    Begin by selecting one of the query rewrite rule types you will create.

    <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/rewrite-rule-types.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=a1ca6d61e701b98db2946c3762b99502" alt="Query rewrite rule types" width="1941" height="1118" data-path="assets/images/5.1/ai-rules/rewrite-rule-types.png" />

    ### Create a rule

    1. Click **+Add**.
    2. In the new table row, complete the required fields, and additional fields as needed.
    3. Click the checkmark to save, or close to cancel the changes.

    ### Edit a rule

    1. Hold the pointer over the rule to edit.
    2. Click the pencil icon.
    3. Enter desired changes and click the checkmark to save, or close to cancel the changes.

    ### Approve/deny rules

    {/* // New or altered rules will need to be approved by a user with the appropriate permissions before the rule can be enabled. */}

    1. Hold the pointer over a rule.
    2. Select the checkbox that displays for that rule.
    3. To modify multiple rules, hold the pointer over each rule and select its corresponding checkbox.
    4. Click **Approve** or **Deny** as needed.

    {/* 
        This is not an explicit option in the rewrite screen. Is this implicit by approval/denial?

        ### Enable/disable a rule

        1. Hold the pointer over a rule.
        2. Select the checkbox that displays for that rule.
        3. To modify multiple rules, hold the pointer over each rule and select its corresponding checkbox.
        4. Click **Enable** or **Disable** as needed.
        */}

    ### Publish a rule

    1. Hold the pointer over a rule.
    2. Select the checkbox that displays for that rule.
    3. To publish multiple rules, hold the pointer over each rule and select its corresponding checkbox.
    4. Click **Publish Selected** to publish the selected rules.

    #### Publish an individual rule

    1. Hold the pointer over a rule.
    2. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/publish-individual-button.png" alt="Publish individual button" /> button.
    3. To confirm, click **Publish**.

    ### Delete rules

    #### Delete a single rule

    1. Hold the pointer over a rule.
    2. Click the trash can.
    3. To confirm, click **Delete**.

    #### Delete multiple rules

    1. Hold the pointer over a rule.
    2. Select the checkbox that displays for that rule.
    3. To delete multiple rules, hold the pointer over each rule and select its corresponding checkbox.
    4. Click **Delete**.
    5. To confirm, click **Delete** again.

    ### Sort rules

    1. Hold the pointer over column titles. A <InlineImage src="/assets/images/5.1/ai-rules/icons/arrow-down-icon.png" alt="Arrow down icon" /> icon displays for some titles to indicate the rules list can be sorted by that column.
    2. Click the title column to sort the rules.

    <Note>The column that is currently sorting the rules list is indicated by an <InlineImage src="/assets/images/5.1/ai-rules/icons/arrow-down-icon.png" alt="Arrow down icon" /> or <InlineImage src="/assets/images/5.1/ai-rules/icons/arrow-up-icon.png" alt="Arrow up icon" /> icon.</Note>

    ### Export rules

    To export the rules list, click **Export**. This generates a `.csv` file that contains your rules.

    ## Columns

    ### Customize columns

    To customize columns:

    1. Hold the pointer over the row of column titles.
    2. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/config-button.png" alt="Config button" />  button.

           <img src="https://mintcdn.com/lucidworks/TTnHmbCCHl-1HFoG/assets/images/5.1/ai-rules/customize-columns-qr.png?fit=max&auto=format&n=TTnHmbCCHl-1HFoG&q=85&s=ceadfee78e65c421d365622724ab20f7" alt="Customize Columns to Display" width="1822" height="1089" data-path="assets/images/5.1/ai-rules/customize-columns-qr.png" />
    3. In the Customize Columns to Display screen, select the checkboxes for the columns you want to display. Clear the checkboxes for columns you do not want to display.
    4. Click **Save**. To exit without saving your changes, click **Cancel**.
  </Accordion>
</AccordionGroup>

<Card title="Experience Optimizer: Rules Manager" class="note-image" href="https://academy.lucidworks.com/experience-optimizer-rules-manager" cta="Take this course on the LucidAcademy." icon="graduation-cap" iconType="duotone">
  The course for **Experience Optimizer: Rules Manager** focuses on how to create and utilize business rules to create more relevant search results for your users.
</Card>

## Signals data

<img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-signals.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=3446da02ee817dccc17e59408b204311" alt="Signals Data" width="2319" height="896" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-signals.png" />

* **Top Null Searches.** The top search terms that yielded 0 results. A null search is considered a poor user experience. Use **Use Query Rewrites in the Rules Editor** to reduce the likelihood of a visitor receiving 0 results.
* **Top Search Terms.** The most commonly searched terms.
* **Top Clicked Products.** The most commonly clicked products or documents. This may include searches, recommendations, static links, or outside referrals.
* **Top Clicked Searches.** The most common searches that resulted in a click.
* **Top Purchased Products.** The most commonly purchased products. This may include searches, recommendations, static links, or referrals.
* **Top Purchased Searches.** The most commonly purchased products that were identified from a search.

<Tip>
  Use query rewrites in the Rules Editor to adapt your search results and guide visitors to top clicked and top purchased products.
</Tip>

<Accordion title="Use Query Rewrites in the Rules Editor">
  This article describes how to use the Rewrites screen in the [Rules Editor](/docs/5/fusion/getting-data-out/query-enhancement/rules-editor).

  ## Query rewrite rule types

  * **Head/Tail.** Replace underperforming queries with queries that produce higher click-through rates. Query improvements always require review before they are published. Schedule the Head/Tail Analysis job to get AI-generated query improvements based on your signals collection. \
    \
    Manually created Head/Tail rewrites must provide an "Improved Query" in a format appropriate to the type of request the rewrite will be applied to.  For Legacy requests, this means a valid Solr query fit for use as the `q` parameter.  For DSL requests this means a JSON string representing the main DSL query. \
    \
    For more information, see:
    * [Underperforming Query Rewriting](/docs/5/fusion/getting-data-out/query-enhancement/underperforming-queries)
    * [Head/Tail Analysis Jobs](/docs/5/fusion/reference/config-ref/jobs/head-tail-analysis)
  * **Misspelling.** Fusion replaces misspelled query terms with their spelling corrections for better search results. Schedule the Token and Phrase Spell Correction job to get AI-generated spelling corrections based on your signals collection. For more information, see [Misspelling Detection](/docs/5/fusion/getting-data-out/query-enhancement/misspelling-detection).
  * **Phrase.** Known phrases are boosted when they appear in new queries. Schedule the Phrase Extraction job to get AI-generated phrases based on your signals collection.
    For more information, see [Phrase Detection](/docs/5/fusion/getting-data-out/query-enhancement/phrase-detection).
  * **Synonym.** Synonyms are used to expand queries so that they include all known synonyms of the query terms. To retrieve AI-generated synonyms based on your signals collection, schedule the [Synonym Detection job](/docs/5/fusion/reference/config-ref/jobs/synonym-detection).
  * **Remove Words** - Remove particular phrases from queries. Unlike other rewrites, these should be entered manually and are not generated by a job. For more information, see [Remove Words](/docs/5/fusion/getting-data-out/query-enhancement/remove-words).

  ## Facets

  ### Facet menu

  <img src="https://mintcdn.com/lucidworks/L5PMnIeZ03zhv8Ti/assets/images/5.6/facet-menu.png?fit=max&auto=format&n=L5PMnIeZ03zhv8Ti&q=85&s=7a220e907feef17ff297b2e8879131ed" alt="Facet rules" width="2946" height="1468" data-path="assets/images/5.6/facet-menu.png" />

  To facet the rules list by **Status** or **Published**, click one of the facet items within the facet categories.

  To facet the rules by **Confidence**, click and drag either slider to set the range of confidence you would like to see:

  <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/rules-facet-confidence.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=52f5364289ced44dda00fa72975c48fa" alt="Confidence facet" style={{ width: "300px" }} width="436" height="194" data-path="assets/images/5.1/ai-rules/rules-facet-confidence.png" />

  <Note>Faceting rules by confidence is not available for Head/Tail rewrites.</Note>

  ### Search

  Enter a term in the search bar to quickly facet your query rewrite rules.

  ## Rules

  Begin by selecting one of the query rewrite rule types you will create.

  <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/rewrite-rule-types.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=a1ca6d61e701b98db2946c3762b99502" alt="Query rewrite rule types" width="1941" height="1118" data-path="assets/images/5.1/ai-rules/rewrite-rule-types.png" />

  ### Create a rule

  1. Click **+Add**.
  2. In the new table row, complete the required fields, and additional fields as needed.
  3. Click the checkmark to save, or close to cancel the changes.

  ### Edit a rule

  1. Hold the pointer over the rule to edit.
  2. Click the pencil icon.
  3. Enter desired changes and click the checkmark to save, or close to cancel the changes.

  ### Approve/deny rules

  {/* // New or altered rules will need to be approved by a user with the appropriate permissions before the rule can be enabled. */}

  1. Hold the pointer over a rule.
  2. Select the checkbox that displays for that rule.
  3. To modify multiple rules, hold the pointer over each rule and select its corresponding checkbox.
  4. Click **Approve** or **Deny** as needed.

  {/* 
    This is not an explicit option in the rewrite screen. Is this implicit by approval/denial?

    ### Enable/disable a rule

    1. Hold the pointer over a rule.
    2. Select the checkbox that displays for that rule.
    3. To modify multiple rules, hold the pointer over each rule and select its corresponding checkbox.
    4. Click **Enable** or **Disable** as needed.
    */}

  ### Publish a rule

  1. Hold the pointer over a rule.
  2. Select the checkbox that displays for that rule.
  3. To publish multiple rules, hold the pointer over each rule and select its corresponding checkbox.
  4. Click **Publish Selected** to publish the selected rules.

  #### Publish an individual rule

  1. Hold the pointer over a rule.
  2. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/publish-individual-button.png" alt="Publish individual button" /> button.
  3. To confirm, click **Publish**.

  ### Delete rules

  #### Delete a single rule

  1. Hold the pointer over a rule.
  2. Click the trash can.
  3. To confirm, click **Delete**.

  #### Delete multiple rules

  1. Hold the pointer over a rule.
  2. Select the checkbox that displays for that rule.
  3. To delete multiple rules, hold the pointer over each rule and select its corresponding checkbox.
  4. Click **Delete**.
  5. To confirm, click **Delete** again.

  ### Sort rules

  1. Hold the pointer over column titles. A <InlineImage src="/assets/images/5.1/ai-rules/icons/arrow-down-icon.png" alt="Arrow down icon" /> icon displays for some titles to indicate the rules list can be sorted by that column.
  2. Click the title column to sort the rules.

  <Note>The column that is currently sorting the rules list is indicated by an <InlineImage src="/assets/images/5.1/ai-rules/icons/arrow-down-icon.png" alt="Arrow down icon" /> or <InlineImage src="/assets/images/5.1/ai-rules/icons/arrow-up-icon.png" alt="Arrow up icon" /> icon.</Note>

  ### Export rules

  To export the rules list, click **Export**. This generates a `.csv` file that contains your rules.

  ## Columns

  ### Customize columns

  To customize columns:

  1. Hold the pointer over the row of column titles.
  2. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/config-button.png" alt="Config button" />  button.

       <img src="https://mintcdn.com/lucidworks/TTnHmbCCHl-1HFoG/assets/images/5.1/ai-rules/customize-columns-qr.png?fit=max&auto=format&n=TTnHmbCCHl-1HFoG&q=85&s=ceadfee78e65c421d365622724ab20f7" alt="Customize Columns to Display" width="1822" height="1089" data-path="assets/images/5.1/ai-rules/customize-columns-qr.png" />
  3. In the Customize Columns to Display screen, select the checkboxes for the columns you want to display. Clear the checkboxes for columns you do not want to display.
  4. Click **Save**. To exit without saving your changes, click **Cancel**.
</Accordion>

## Predictive Merchandiser and Experience Optimizer

Predictive Merchandiser and Experience Optimizer are both AI-powered tools that provide insights, customer recommendations, and search optimization in a single comprehensive product.

<img src="https://mintcdn.com/lucidworks/xQr7Fxxc7lI5hKz-/assets/images/predictive-merchandiser/pm-board.png?fit=max&auto=format&n=xQr7Fxxc7lI5hKz-&q=85&s=5ee73e0b97c4fdf4525922931bfc134a" alt="Predictive Merchandiser Board" width="1477" height="865" data-path="assets/images/predictive-merchandiser/pm-board.png" />

Predictive Merchandiser and Experience Optimizer are separate offerings from Fusion. See the [Predictive Merchandiser documentation](/docs/5/fusion/getting-data-out/curating-your-search-experience/predictive-merchandiser/overview) for more information.

## Rules

<img src="https://mintcdn.com/lucidworks/VKnUHJXP6sWH55ak/assets/images/5.6/rules-ui-business-rules-56.png?fit=max&auto=format&n=VKnUHJXP6sWH55ak&q=85&s=e9ddc4d48d9909e9654a02bdf469ff3e" alt="Rules Editor Business Rules" width="2429" height="1293" data-path="assets/images/5.6/rules-ui-business-rules-56.png" />

The Rules screen is used to create [Business Rules](/docs/5/fusion/getting-data-out/query-enhancement/business-rules/overview) within the Rules Editor.

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](/docs/5/fusion/reference/config-ref/pipeline-stages/query-stages/query-rules-query-stage) of the query pipeline.

Learn how to use the **Use Business Rules in the Rules Editor**.

<Accordion title="Use Business Rules in the Rules Editor">
  This article describes how to use the [Business Rules](/docs/5/fusion/getting-data-out/query-enhancement/business-rules/overview) screen in the [Rules Editor](/docs/5/fusion/getting-data-out/query-enhancement/rules-editor).

  <Card title="Query Rewriting with Business Rules and Search Rewrites" class="note-image" href="https://academy.lucidworks.com/query-rewriting-with-business-rules-and-search-rewrites" cta="Take this course on the LucidAcademy." icon="graduation-cap" iconType="duotone">
    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.
  </Card>

  ## Facet rules

  ### Facet menu

  <img src="https://mintcdn.com/lucidworks/L5PMnIeZ03zhv8Ti/assets/images/5.6/facet-menu.png?fit=max&auto=format&n=L5PMnIeZ03zhv8Ti&q=85&s=7a220e907feef17ff297b2e8879131ed" alt="Facet rules" width="2946" height="1468" data-path="assets/images/5.6/facet-menu.png" />

  To 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.

       <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/rules-facets-date.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=8e2c03acba6766993d51cc815d830410" alt="Created date start value" style={{ width: "300px" }} width="440" height="344" data-path="assets/images/5.1/ai-rules/rules-facets-date.png" />

  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.

  ### Search

  Enter a term in the search bar to quickly facet your business rules.

  ## Rules

  ### Create a rule

  1. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/add-button-1.png" alt="Add button large" /> button in the top-right corner of the card. Alternatively, click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/add-button-2.png" alt="Add button small" /> button in the bottom-left corner of the card. The **New Rule** dialog box will appear.

       <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/new-rule.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=37992007ed2233ee6cac599ce2eb6dac" alt="New rule" width="2560" height="1344" data-path="assets/images/5.1/ai-rules/new-rule.png" />
  2. Complete the required fields, at a minimum.

     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                  |                                                                                                                                                                                                                                                                                                        |
     | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
     | General                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | Condition                                                                                                                                                                                                                        | Action                                                                                                                                                                                                                                                                                                 |
     | In the **General** column, only the **Name** field is required. Other fields are optional: <ul><li>**Description** is an arbitrary string you can use to describe this rule.</li> <li>**Rule Group** can be a user-defined group that you use to organize your rules.</li>  <li>**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.</li> <li>**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.</li> <li>**Enabled** means that this rule is applied but not necessarily published. Disabling a rule helps ensure that it is not accidentally published.</li></ul> | Conditions are triggers that activate the rule when they match the current date and time, query, or field values. See [Rule conditions](/docs/5/fusion/getting-data-out/query-enhancement/query-rewriting) for more information. | A rule can take different types of actions when the specified conditions are met. See [Action types](/docs/5/fusion/getting-data-out/query-enhancement/query-rewriting) for more information. You can also create [custom actions](/docs/5/fusion/getting-data-out/query-enhancement/query-rewriting). |

     <Tip>Hover over the <InlineImage src="/assets/images/5.1/ai-rules/icons/info-icon.png" alt="Info icon" /> icon for more information.</Tip>
  3. Once complete, click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/save-buttong.png" alt="Save button green" /> button.

  ### Copy a rule

  1. Hover over a rule. A row of buttons will appear on the right.
  2. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/copy-button.png" alt="Copy button" /> button. The **Copy Rule** dialog box will appear.

       <img src="https://mintcdn.com/lucidworks/TTnHmbCCHl-1HFoG/assets/images/5.1/ai-rules/copy-rule.png?fit=max&auto=format&n=TTnHmbCCHl-1HFoG&q=85&s=7f1ec5c812c791b509154b2d24c1641d" alt="Copy rule" width="2560" height="1344" data-path="assets/images/5.1/ai-rules/copy-rule.png" />
  3. At a minimum, change the title of the rule.
  4. Once complete, click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/save-buttong.png" alt="Save button green" /> button.

  ### Edit a rule

  1. Hover over a rule. A row of buttons will appear on the right.
  2. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/edit-button.png" alt="Edit button" /> button. The **Edit Rule** dialog box appears.

       <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/edit-rule.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=0b22a2d898cf85092f6243e5f217d677" alt="Edit rule" width="2560" height="1344" data-path="assets/images/5.1/ai-rules/edit-rule.png" />
  3. Make your desired changes to the rule.
  4. Once complete, click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/save-buttong.png" alt="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 <InlineImage src="/assets/images/5.1/ai-rules/buttons/enable-button.png" alt="Enable button" /> button to enable the selected rules, or click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/disable-button.png" alt="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 <InlineImage src="/assets/images/5.1/ai-rules/buttons/publish-selected-button.png" alt="Publish selected button" />button 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 <InlineImage src="/assets/images/5.1/ai-rules/buttons/tag-button.png" alt="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 <InlineImage src="/assets/images/5.1/ai-rules/buttons/add-button-1.png" alt="Add button large" />  button to add the tag to the rule.

       <Note>
         See [General Configuration Tags](/docs/5/fusion/getting-data-out/query-enhancement/business-rules/general-config) for information about how to use tagnames in the request URL to fire specific rules.
       </Note>

  ### Delete rules

  #### Delete a single rule

  1. Hover over a rule. A row of buttons will appear on the right.
  2. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/delete-button-2.png" alt="Delete button small" /> button. A confirmation box will appear.
  3. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/delete-button-1g.png" alt="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 <InlineImage src="/assets/images/5.1/ai-rules/buttons/delete-button-1r.png" alt="Delete button large red" /> button to delete the selected rules. A confirmation box will appear.
  5. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/delete-button-1g.png" alt="Delete button large green" /> button to confirm.

  ### Sort rules

  1. Hover over column titles. A <InlineImage src="/assets/images/5.1/ai-rules/icons/arrow-down-icon.png" alt="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.

  <Note>The column that is currently sorting the rules list is indicated by an <InlineImage src="/assets/images/5.1/ai-rules/icons/arrow-down-icon.png" alt="Arrow down icon" /> or <InlineImage src="/assets/images/5.1/ai-rules/icons/arrow-up-icon.png" alt="Arrow up icon" /> icon.</Note>

  ### Export rules

  To export the rules list, simply click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/export-button.png" alt="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 <InlineImage src="/assets/images/5.1/ai-rules/buttons/config-button.png" alt="Config button" /> button will appear on the right.
  2. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/config-button.png" alt="Config button" /> button. The **Customize Columns to Display** dialog box will appear.

       <img src="https://mintcdn.com/lucidworks/TTnHmbCCHl-1HFoG/assets/images/5.1/ai-rules/customize-columns-br.png?fit=max&auto=format&n=TTnHmbCCHl-1HFoG&q=85&s=c835f109d3cb5d5a845a3f0a7166f9db" alt="Customize Columns to Display" width="1850" height="1085" data-path="assets/images/5.1/ai-rules/customize-columns-br.png" />
  3. Click the checkboxes to select or deselect the columns you want to display.
  4. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/save-buttonb.png" alt="Save button blue" />  button to save your changes.
</Accordion>

### UI elements

#### Facets

* **Action.** The [built-in rule action](/docs/5/fusion/getting-data-out/query-enhancement/business-rules/overview) for the rule.
* **Status.** Whether a rule is enabled or disabled.
* **Published.** Whether or not a rule has been published.
* **Created Date.** The date the rule was created.
* **Expiration Date.** The date the rule will expire.

#### Rules list

The rules list can be faceted, searched, or sorted according to the various values the rules hold.

## Rewrite

<img src="https://mintcdn.com/lucidworks/VKnUHJXP6sWH55ak/assets/images/5.6/rules-ui-rewrite-56.png?fit=max&auto=format&n=VKnUHJXP6sWH55ak&q=85&s=85ed727ddc52369ef671661ce633b570" alt="Rules Editor Query Rewrites" width="2427" height="1307" data-path="assets/images/5.6/rules-ui-rewrite-56.png" />

Learn how to use the **Use Query Rewrites in the Rules Editor**.

<Accordion title="Use Query Rewrites in the Rules Editor">
  This article describes how to use the Rewrites screen in the [Rules Editor](/docs/5/fusion/getting-data-out/query-enhancement/rules-editor).

  ## Query rewrite rule types

  * **Head/Tail.** Replace underperforming queries with queries that produce higher click-through rates. Query improvements always require review before they are published. Schedule the Head/Tail Analysis job to get AI-generated query improvements based on your signals collection. \
    \
    Manually created Head/Tail rewrites must provide an "Improved Query" in a format appropriate to the type of request the rewrite will be applied to.  For Legacy requests, this means a valid Solr query fit for use as the `q` parameter.  For DSL requests this means a JSON string representing the main DSL query. \
    \
    For more information, see:
    * [Underperforming Query Rewriting](/docs/5/fusion/getting-data-out/query-enhancement/underperforming-queries)
    * [Head/Tail Analysis Jobs](/docs/5/fusion/reference/config-ref/jobs/head-tail-analysis)
  * **Misspelling.** Fusion replaces misspelled query terms with their spelling corrections for better search results. Schedule the Token and Phrase Spell Correction job to get AI-generated spelling corrections based on your signals collection. For more information, see [Misspelling Detection](/docs/5/fusion/getting-data-out/query-enhancement/misspelling-detection).
  * **Phrase.** Known phrases are boosted when they appear in new queries. Schedule the Phrase Extraction job to get AI-generated phrases based on your signals collection.
    For more information, see [Phrase Detection](/docs/5/fusion/getting-data-out/query-enhancement/phrase-detection).
  * **Synonym.** Synonyms are used to expand queries so that they include all known synonyms of the query terms. To retrieve AI-generated synonyms based on your signals collection, schedule the [Synonym Detection job](/docs/5/fusion/reference/config-ref/jobs/synonym-detection).
  * **Remove Words** - Remove particular phrases from queries. Unlike other rewrites, these should be entered manually and are not generated by a job. For more information, see [Remove Words](/docs/5/fusion/getting-data-out/query-enhancement/remove-words).

  ## Facets

  ### Facet menu

  <img src="https://mintcdn.com/lucidworks/L5PMnIeZ03zhv8Ti/assets/images/5.6/facet-menu.png?fit=max&auto=format&n=L5PMnIeZ03zhv8Ti&q=85&s=7a220e907feef17ff297b2e8879131ed" alt="Facet rules" width="2946" height="1468" data-path="assets/images/5.6/facet-menu.png" />

  To facet the rules list by **Status** or **Published**, click one of the facet items within the facet categories.

  To facet the rules by **Confidence**, click and drag either slider to set the range of confidence you would like to see:

  <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/rules-facet-confidence.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=52f5364289ced44dda00fa72975c48fa" alt="Confidence facet" style={{ width: "300px" }} width="436" height="194" data-path="assets/images/5.1/ai-rules/rules-facet-confidence.png" />

  <Note>Faceting rules by confidence is not available for Head/Tail rewrites.</Note>

  ### Search

  Enter a term in the search bar to quickly facet your query rewrite rules.

  ## Rules

  Begin by selecting one of the query rewrite rule types you will create.

  <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/rewrite-rule-types.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=a1ca6d61e701b98db2946c3762b99502" alt="Query rewrite rule types" width="1941" height="1118" data-path="assets/images/5.1/ai-rules/rewrite-rule-types.png" />

  ### Create a rule

  1. Click **+Add**.
  2. In the new table row, complete the required fields, and additional fields as needed.
  3. Click the checkmark to save, or close to cancel the changes.

  ### Edit a rule

  1. Hold the pointer over the rule to edit.
  2. Click the pencil icon.
  3. Enter desired changes and click the checkmark to save, or close to cancel the changes.

  ### Approve/deny rules

  {/* // New or altered rules will need to be approved by a user with the appropriate permissions before the rule can be enabled. */}

  1. Hold the pointer over a rule.
  2. Select the checkbox that displays for that rule.
  3. To modify multiple rules, hold the pointer over each rule and select its corresponding checkbox.
  4. Click **Approve** or **Deny** as needed.

  {/* 
    This is not an explicit option in the rewrite screen. Is this implicit by approval/denial?

    ### Enable/disable a rule

    1. Hold the pointer over a rule.
    2. Select the checkbox that displays for that rule.
    3. To modify multiple rules, hold the pointer over each rule and select its corresponding checkbox.
    4. Click **Enable** or **Disable** as needed.
    */}

  ### Publish a rule

  1. Hold the pointer over a rule.
  2. Select the checkbox that displays for that rule.
  3. To publish multiple rules, hold the pointer over each rule and select its corresponding checkbox.
  4. Click **Publish Selected** to publish the selected rules.

  #### Publish an individual rule

  1. Hold the pointer over a rule.
  2. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/publish-individual-button.png" alt="Publish individual button" /> button.
  3. To confirm, click **Publish**.

  ### Delete rules

  #### Delete a single rule

  1. Hold the pointer over a rule.
  2. Click the trash can.
  3. To confirm, click **Delete**.

  #### Delete multiple rules

  1. Hold the pointer over a rule.
  2. Select the checkbox that displays for that rule.
  3. To delete multiple rules, hold the pointer over each rule and select its corresponding checkbox.
  4. Click **Delete**.
  5. To confirm, click **Delete** again.

  ### Sort rules

  1. Hold the pointer over column titles. A <InlineImage src="/assets/images/5.1/ai-rules/icons/arrow-down-icon.png" alt="Arrow down icon" /> icon displays for some titles to indicate the rules list can be sorted by that column.
  2. Click the title column to sort the rules.

  <Note>The column that is currently sorting the rules list is indicated by an <InlineImage src="/assets/images/5.1/ai-rules/icons/arrow-down-icon.png" alt="Arrow down icon" /> or <InlineImage src="/assets/images/5.1/ai-rules/icons/arrow-up-icon.png" alt="Arrow up icon" /> icon.</Note>

  ### Export rules

  To export the rules list, click **Export**. This generates a `.csv` file that contains your rules.

  ## Columns

  ### Customize columns

  To customize columns:

  1. Hold the pointer over the row of column titles.
  2. Click the <InlineImage src="/assets/images/5.1/ai-rules/buttons/config-button.png" alt="Config button" />  button.

       <img src="https://mintcdn.com/lucidworks/TTnHmbCCHl-1HFoG/assets/images/5.1/ai-rules/customize-columns-qr.png?fit=max&auto=format&n=TTnHmbCCHl-1HFoG&q=85&s=ceadfee78e65c421d365622724ab20f7" alt="Customize Columns to Display" width="1822" height="1089" data-path="assets/images/5.1/ai-rules/customize-columns-qr.png" />
  3. In the Customize Columns to Display screen, select the checkboxes for the columns you want to display. Clear the checkboxes for columns you do not want to display.
  4. Click **Save**. To exit without saving your changes, click **Cancel**.
</Accordion>

### UI elements

#### Facets

* **Status.** Whether a rule is enabled or disabled.
* **Published.** Whether or not a rule has been published.
* **Confidence.** The confidence score for the rule. A confidence score is automatically set by Fusion. It can be manually set for user-created rules. The confidence score is used, in part, to decided whether a rule is automatically published or not. See [Query Rewriting concepts](/docs/5/fusion/getting-data-out/query-enhancement/query-rewriting) for more information.

  <Note>
    **Confidence** is not used for Head/Tail query rewrites.
  </Note>

#### Rules list

You can facet, search, or sort the rules list according to the values the rules hold.

##### Rule type selectors

There are buttons at the top of the rules list that allow you to choose what query rewrite rule types you would like to work with:

<img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-rewrite-rule-types.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=13cc13486c46fc4635afdd1b83cc134a" alt="Query rewrite rule types" width="1842" height="1089" data-path="assets/images/5.1/ai-rules/ui/rules-ui-rewrite-rule-types.png" />

* **Head/Tail.** Replace underperforming queries with queries that produce higher click-through rates. Query improvements always require review before they are published. Schedule the Head/Tail Analysis job to get AI-generated query improvements based on your signals collection. See [Underperforming Query Rewriting](/docs/5/fusion/getting-data-out/query-enhancement/underperforming-queries).
* **Misspelling.** Fusion replaces misspelled query terms with their spelling corrections for better search results. Schedule the Token and Phrase Spell Correction job to get AI-generated spelling corrections based on your signals collection. See [Misspelling Detection](/docs/5/fusion/getting-data-out/query-enhancement/misspelling-detection).
* **Phrase.** Known phrases are boosted when they appear in new queries. Schedule the Phrase Extraction job to get AI-generated phrases based on your signals collection. See [Phrase Detection](/docs/5/fusion/getting-data-out/query-enhancement/phrase-detection).
* **Synonym.** Synonyms expand queries so that they include all known synonyms of the query terms. Schedule the Synonym Detection job to get AI-generated synonyms based on your signals collection. See [Synonym Detection](/docs/5/fusion/reference/config-ref/jobs/synonym-detection).
* **Remove Words.** Remove particular phrases from queries. Unlike other rewrites, these should be entered manually and are not generated by a job. See [Remove Words](/docs/5/fusion/getting-data-out/query-enhancement/remove-words).

## Templates

The Templates screen in the Rules Editor allows you to design, test, and implement a wide variety of search experiences. Results are conditionally delivered from multiple different query pipelines, enabling you to use Fusion’s search, browse, and AI-driven functionality throughout your site.

<img src="https://mintcdn.com/lucidworks/3Ch7Gf3ey98GnjMH/assets/images/predictive-merchandiser/templates/template-manager02.png?fit=max&auto=format&n=3Ch7Gf3ey98GnjMH&q=85&s=8cb973581764e325df6a52ab89cc0b7a" alt="Template Manager" width="2440" height="1295" data-path="assets/images/predictive-merchandiser/templates/template-manager02.png" />

Templates are only available with a valid license for [Predictive Merchandiser](/docs/5/fusion/getting-data-out/curating-your-search-experience/predictive-merchandiser/overview). If available, you will see the templates icon in the left navigation panel: <InlineImage src="/assets/images/predictive-merchandiser/templates/icon-templates.png" />

## Simulator

The Simulator provides an interactive preview of how your staged rules affect relevancy, using your search data and a simple search interface. When you enter a query, the Simulator shows you the triggered rules, in the order in which they were triggered, along with any triggered facets.

<img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/simulator-screen.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=4484ba28ba58c2c4769bb4f9b5c6bd4d" alt="Simulator 5.x" width="2434" height="1332" data-path="assets/images/5.1/ai-rules/simulator-screen.png" />

You can edit any of the triggered rules, then re-run the query to see new results.

The Simulator sends requests to the `COLLECTION_NAME_rules_simulator` query profile, which you can configure to point to any pipeline and collection in your app.

The Simulator is only visible in the Rules Editor if you *do not* have a valid license for [Predictive Merchandiser](/docs/5/fusion/getting-data-out/curating-your-search-experience/predictive-merchandiser/overview). If available, you will see the simulator icon in the left navigation panel.

### Search

<img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/simulator-example-query.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=fa5cc15f5977eeb7206e44b7a28ddcc7" alt="Simulator search bar" width="1023" height="104" data-path="assets/images/5.1/ai-rules/simulator-example-query.png" />

Use the search bar in the top nav panel to simulate, or preview, your staged rules.

### Rule indicators

After entering a search query, the active rules affecting the results are displayed above the results. For example, a query for the term `keyboard` with a query rewrite rule would display an indicator for the rewritten query `wireless keyboard` in the left panel of the Simulator:

<img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/simulator-example-query02-framed.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=5dce1d8b152e3743cff611737ebb66b8" alt="Active query rewrite rules" width="1082" height="501" data-path="assets/images/5.1/ai-rules/simulator-example-query02-framed.png" />

You can edit the query rewrite rule by hovering over this indicator and clicking the edit button. A dialog box appears:

<img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/simulator-example-query03.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=41228be1bba497bb8bcba710f7910b43" alt="App picker" width="350" data-path="assets/images/5.1/ai-rules/simulator-example-query03.png" />

Similarly, when a business rule is triggered by a search condition, it appears in the right panel of the Simulator:

<img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/simulator-example-query04.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=c7ad88b2d40d7948ed9be85aa0161ef0" alt="Active business rules" width="400" data-path="assets/images/5.1/ai-rules/simulator-example-query04.png" />

## Analytics

<img src="https://mintcdn.com/lucidworks/VKnUHJXP6sWH55ak/assets/images/5.6/rules-ui-analytics-56.png?fit=max&auto=format&n=VKnUHJXP6sWH55ak&q=85&s=f40f3115ee3173aa1ea2880abaadab6b" alt="Rules Editor Analytics" width="2731" height="1559" data-path="assets/images/5.6/rules-ui-analytics-56.png" />

The Analytics screen is available as part of the [Predictive Merchandiser](#predictive-merchandiser-and-experience-optimizer), a separate offering from Fusion. See the [Predictive Merchandiser documentation](/docs/5/fusion/getting-data-out/curating-your-search-experience/predictive-merchandiser/overview) for more information.

Learn how to use the **Use the Analytics Screen in the Rules Editor**.

<Accordion title="Use the Analytics Screen in the Rules Editor">
  This article describes how to use the [Analytics screen](/docs/5/fusion/getting-data-out/query-enhancement/rules-editor) in the [Rules Editor](/docs/5/fusion/getting-data-out/query-enhancement/rules-editor).

  <Note>Job configuration affects the data that displays on the dashboard. For example, the [`COLLECTION_NAME_session_rollup` job](/docs/5/fusion/reference/config-ref/jobs/aggregations/built-in-sql-aggregation-jobs) aggregates related user activity into a session signal that contains activity count, duration, and keywords (based on user search terms).</Note>

  ### UI elements

  #### Data date range

  * **Quick Range Selectors.** Click one of the quick range selectors to facet your data.

      <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-date.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=ba2e682955eff2420ae49b54ab786f3c" alt="Data date range selectors" width="927" height="117" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-date.png" />
  * **Calendar Selector.** Use the calendar selector to specify a start and end date and time facet for your data.

      <img style={{ width: "300px" }} src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-date-calendar.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=5452da040facd2f8ebaa38a2faa84b1f" width="559" height="618" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-date-calendar.png" />

  #### Visitor data

  * **Data Cards**

      <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-visitor-cards.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=b3f43504286aaad9934106ec26125f4c" alt="Data cards" width="2319" height="369" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-visitor-cards.png" />

    * **Site Visits.** The total number of visits.
    * **Total Searches.** The total number of searches performed.
    * **Unique Visitors.** The number of unique visitors to your site.
    * **Average Session.** The average length of time spent on your site.
  * **Data Graph.** Detailed information for the selected data card.

      <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-visitor-graph.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=f195437a3c20aeba43e26c1e4c3d7786" alt="Data graph" width="2318" height="672" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-visitor-graph.png" />

  ## View data by date range

  The Rules Editor analytics allows you to view data by a date range. To do this, you can either:

  * Click one of the date range presets:

      <img src="https://mintcdn.com/lucidworks/TTnHmbCCHl-1HFoG/assets/images/5.1/ai-rules/date-range-presets.png?fit=max&auto=format&n=TTnHmbCCHl-1HFoG&q=85&s=c9972796555f38ee83888bcb2f4c5098" alt="Date range by preset" width="1026" height="156" data-path="assets/images/5.1/ai-rules/date-range-presets.png" />
  * Click the date range details to display and select your range on the calendar that appears:

      <img src="https://mintcdn.com/lucidworks/TTnHmbCCHl-1HFoG/assets/images/5.1/ai-rules/date-range-calendar.png?fit=max&auto=format&n=TTnHmbCCHl-1HFoG&q=85&s=af256a6109a4a9f3139ea133dd2e30c0" alt="Date range by calendar" width="1220" height="876" data-path="assets/images/5.1/ai-rules/date-range-calendar.png" />

  ## View additional card details

  Click one of the analytics cards to view additional details for that card’s data.

  ## Configure Analytics cards

  1. Hover over one of the cards.
  2. Click the **Edit** button that appears:  <img className="inline-image" alt="Edit Analytics card" src="https://mintcdn.com/lucidworks/rffsSynuMpAuFk9Z/assets/images/5.3/pm-analytics-edit-card.png?fit=max&auto=format&n=rffsSynuMpAuFk9Z&q=85&s=51930e81e947945c29c2eb5cdcd1c83b" width="65" height="50" data-path="assets/images/5.3/pm-analytics-edit-card.png" />
  3. Complete the form that appears.
  4. Click the **Save** button.

  If the data is empty, check to make sure the date range includes the data you want to display.

  <img src="https://mintcdn.com/lucidworks/rffsSynuMpAuFk9Z/assets/images/5.3/pm-analytics-date-range.png?fit=max&auto=format&n=rffsSynuMpAuFk9Z&q=85&s=158a4215848ce9ec97d3685bb1826a91" alt="Analytics date range" width="783" height="123" data-path="assets/images/5.3/pm-analytics-date-range.png" />
</Accordion>

### UI elements

#### Data date range

* **Quick Range Selectors.** Click one of the quick range selectors to facet your data.

  <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-date.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=ba2e682955eff2420ae49b54ab786f3c" alt="Data date range selectors" width="927" height="117" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-date.png" />
* **Calendar Selector.** Use the calendar selector to specify a start and end date and time facet for your data.

  <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-date-calendar.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=5452da040facd2f8ebaa38a2faa84b1f" alt="Calendar selector" width="400" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-date-calendar.png" />

#### Visitor data

* **Data Cards**

  <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-visitor-cards.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=b3f43504286aaad9934106ec26125f4c" alt="Data cards" width="2319" height="369" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-visitor-cards.png" />

  * **Site Visits.** The total number of visits.
  * **Total Searches.** The total number of searches performed.
  * **Unique Visitors.** The number of unique visitors to your site.
  * **Average Session.** The average length of time spent on your site.
* **Data Graph.** Detailed information for the selected data card.

  <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-visitor-graph.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=f195437a3c20aeba43e26c1e4c3d7786" alt="Data graph" width="2318" height="672" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-visitor-graph.png" />

## Learn more

<AccordionGroup>
  <Accordion title="Keep Rules Consistent Between Clusters">
    This article teaches you how to keep business rules consistent between clusters. Use a `PUT` API call to the Query Rewrite) API’s `/query-rewrite/instances` endpoint for bulk operations. The JSON payload sent with the `PUT` call must adhere to the following format:

    ```json theme={"dark"}
    {
    "create": [<object array>],
    "update": [<object array>],
    "delete": [<item array>]
    }
    ```

    * **`create`**. If the rule does not exist, [create it](#create-a-rule).
    * **`update`**. If the rule exists, [update it](#use-update) to use the latest values.
    * **`delete`**. If the rule exists, [delete it](#delete-rules).

    Fusion generates a unique `id` value for every rule. The API operations use this value as a reference point.

    The instructions in the sections below use these example values:

    | Parameter                       | Value 2+                         |
    | ------------------------------- | -------------------------------- |
    | **Development cluster**         | Address                          |
    | https\://FUSION\_HOST\_DEV:6764 | Username                         |
    | DEV\_USER                       | Password                         |
    | DEV\_PASSWORD                   | App name                         |
    | DEV\_APP\_NAME 2+               | **Production cluster**           |
    | Address                         | https\://FUSION\_HOST\_PROD:6764 |
    | Username                        | PROD\_USER                       |
    | Password                        | PROD\_PASSWORD                   |
    | App name                        | PROD\_APP\_NAME                  |

    <Note>When you use the API to conduct bulk rules operations, you must publish the changes in the UI.  1. Log into Fusion with the same user credentials that you used to make the bulk API rules operations. 2. Navigate to **Relevance > Rules** to access the rules editor. 3. Click the **Publish** button.</Note>

    ## Export rules

    In these examples, you’ll export rules from an app on a development cluster. This is useful if you have a large number of rule changes you need to port from a development cluster to a production cluster.

    ### All rules

    Export all rules from the development cluster by sending a `GET` API call to the `/query-rewrite/instances` endpoint:

    ```curl theme={"dark"}
    curl -X 'GET' \
      -u DEV_USER:DEV_PASSWORD \
      'https://FUSION_HOST_DEV:6764/api/apps/DEV_APP_NAME/query-rewrite/instances' \
      -H 'accept: application/json' \
      > exported-rules.json
    ```

    This outputs your rules to a new JSON file, **exported-rules.json**. The result resembles the following:

    ```json expandable theme={"dark"}
    [{
            "type": "pinned",
            "id": "NqYec4R7pG",
            "name": "Featured - Fusion 5.9",
            "createdOn": "2021-06-21T17:28:19.800Z",
            "updatedOn": "2021-06-21T17:28:19.800Z",
            "enabled": true,
            "matching": "keywords",
            "priority": 1,
            "search_terms": ["*:*"],
            ...  
        }, {
            "type": "pinned",
            "id": "uEvL1NBXba",
            "name": "Featured - Fusion 5.9",
            "createdOn": "2021-06-21T17:29:59.863Z",
            "updatedOn": "2021-06-21T17:29:59.863Z",
            "enabled": true,
            "matching": "keywords",
            "priority": 1,
            "search_terms": ["*:*"],
            ...  
        }]
    ```

    ### Specific rules

    You can specify which rules you want to export by adding parameters to the API endpoint. For example, if you want to export synonym rules only, send a `GET` API call to `/query-rewrite/instances?type=synonym`. If you want to export a list of rules that are disabled, use `/query-rewrite/instances?enabled=false`.

    Use the same `GET` API call, but change the endpoint:

    ```curl theme={"dark"}
    curl -X 'GET' \
      -u DEV_USER:DEV_PASSWORD \
      'https://FUSION_HOST_DEV:6764/api/apps/DEV_APP_NAME/query-rewrite/instances?type=synonym' \
      -H 'accept: application/json' \
      > exported-rules.json
    ```

    ## Use `create`

    In this example, you’ll recreate the rules from your development cluster on your production cluster.

    1. Manually reformat the JSON so it uses the following format:
       ```json theme={"dark"}
       {
       "create": [<object array>]
       }
       ```
       We are recreating the development cluster’s rules on the production cluster, so we can use `create` only. Replace `[<object array>]` with the contents of **exported-rules.json**. For example:
       ```json theme={"dark"}
       {
        "create": [{
              "type": "pinned",
              "id": "NqYec4R7pG",
              "name": "Featured - Fusion 5.9",
              "createdOn": "2021-06-21T17:28:19.800Z",
              "updatedOn": "2021-06-21T17:28:19.800Z",
              "enabled": true,
              "matching": "keywords",
              "priority": 1,
              "search_terms": ["*:*"],
              ...  
          }, {
              "type": "pinned",
              "id": "uEvL1NBXba",
              "name": "Featured - Fusion 5.9",
              "createdOn": "2021-06-21T17:29:59.863Z",
              "updatedOn": "2021-06-21T17:29:59.863Z",
              "enabled": true,
              "matching": "keywords",
              "priority": 1,
              "search_terms": ["*:*"],
              ...  
          },
          ...  
        ]}
       ```
    2. Save the file.
    3. Send a `PUT` API call to the `/query-rewrite/instances` endpoint to recreate the rules from the development cluster on the production cluster:
       ```bash theme={"dark"}
       curl -X 'PUT' \
        -u PROD_USER:PROD_PASSWORD \
        'https://FUSION_HOST_PROD:6764/api/apps/PROD_APP_NAME/query-rewrite/instances' \
        -H 'accept: application/octet-stream' \
        -H 'Content-Type: application/json' \
        -d @exported-rules.json
       ```

    <Tip>
      You may have to specify the absolute path to your rules JSON file. For example, `-d @/Users/johndoe/exported-rules.json`.
    </Tip>

    4. Verify that the `PUT` API was successful by checking the Fusion UI or [fetching the rules with the API](#export-rules).

    ## Use `update`

    1. Manually reformat the JSON so it uses the following format:
       ```json theme={"dark"}
       {
       "update": [<object array>]
       }
       ```
       Replace `[<object array>]` with the contents of **exported-rules.json**. For example:
       ```json theme={"dark"}
       {
        "update": [{
              "type": "pinned",
              "id": "NqYec4R7pG",
              "name": "Featured - Fusion 5.9",
              "createdOn": "2021-06-21T17:28:19.800Z",
              "updatedOn": "2021-06-21T17:28:19.800Z",
              "enabled": true,
              "matching": "keywords",
              "priority": 1,
              "search_terms": ["*:*"],
              ...  
          }, {
              "type": "pinned",
              "id": "uEvL1NBXba",
              "name": "Featured - Fusion 5.9",
              "createdOn": "2021-06-21T17:29:59.863Z",
              "updatedOn": "2021-06-21T17:29:59.863Z",
              "enabled": true,
              "matching": "keywords",
              "priority": 1,
              "search_terms": ["*:*"],
              ...  
          },
          ...  
        ]}
       ```
    2. Save the file.
    3. Send a `PUT` API call to the `/query-rewrite/instances` endpoint to update the production cluster with the rules from the development cluster:
       ```bash theme={"dark"}
       curl -X 'PUT' \
        -u PROD_USER:PROD_PASSWORD \
        'https://FUSION_HOST_PROD:6764/api/apps/PROD_APP_NAME/query-rewrite/instances' \
        -H 'accept: application/octet-stream' \
        -H 'Content-Type: application/json' \
        -d @exported-rules.json
       ```

    ## Use `delete`

    In some cases, you may want to delete rules in bulk. For example, if you [created rules](#create-a-rule) using the steps above but decide you want to undo that action.

    The `delete` bulk operation uses a different format than `create` and `update`. Instead of passing the entire rules JSON as an object array, you must pass the rule `id` values as an item array.

    1. Manually reformat the JSON so it uses the following format:
       ```json theme={"dark"}
       {
       "delete": [<item array>]
       }
       ```
       Replace `<item array>` with the `id` values of the rules you want to delete. These values must be comma separated and wrapped in double quotes (`"`). For example:
       ```json theme={"dark"}
       {
        "delete": ["NqYec4R7pG", "uEvL1NBXba", ... ]}
       ```
    2. Save the file.
    3. Send a `PUT` API call to the `/query-rewrite/instances` endpoint to update the production cluster with the rules from the development cluster:
       ```bash theme={"dark"}
       curl -X 'PUT' \
        -u PROD_USER:PROD_PASSWORD \
        'https://FUSION_HOST_PROD:6764/api/apps/PROD_APP_NAME/query-rewrite/instances' \
        -H 'accept: application/octet-stream' \
        -H 'Content-Type: application/json' \
        -d @exported-rules.json
       ```

    ## Use `create` with `update`

    You may want to determine which rules to include in the `create` array and which to include in the `update` array, but it can be difficult to determine which rules already exist. Fortunately, the operations don’t conflict:

    * **`create`**. If the rule does not exist, [create it](#create-a-rule).
    * **`update`**. If the rule exists, [update it](#use-update) to use the latest values.

    There’s no need to separate the rules. You can replace `[<object array>]` for `create` and `update` with the *same* rules JSON to create the missing rules and update the existing rules.

    1. Manually reformat the JSON so it uses the following format:
       ```json theme={"dark"}
       {
       "create": [<object array>],
       "update": [<object array>]
       }
       ```
       Replace `[<object array>]` with the contents of **exported-rules.json**. For example:
       ```json theme={"dark"}
       {
        "create": [{
              "type": "pinned",
              "id": "NqYec4R7pG",
              "name": "Featured - Fusion 5.9",
              "createdOn": "2021-06-21T17:28:19.800Z",
              "updatedOn": "2021-06-21T17:28:19.800Z",
              "enabled": true,
              "matching": "keywords",
              "priority": 1,
              "search_terms": ["*:*"],
              ...  
          }
          ...  
        ],
        "update": [{
              "type": "pinned",
              "id": "NqYec4R7pG",
              "name": "Featured - Fusion 5.9",
              "createdOn": "2021-06-21T17:28:19.800Z",
              "updatedOn": "2021-06-21T17:28:19.800Z",
              "enabled": true,
              "matching": "keywords",
              "priority": 1,
              "search_terms": ["*:*"],
              ...  
          }
          ...  
        ]
       }
       ```
    2. Save the file.
    3. Send a `PUT` API call to the `/query-rewrite/instances` endpoint to update the production cluster with the rules from the development cluster:
       ```bash theme={"dark"}
       curl -X 'PUT' \
        -u PROD_USER:PROD_PASSWORD \
        'https://FUSION_HOST_PROD:6764/api/apps/PROD_APP_NAME/query-rewrite/instances' \
        -H 'accept: application/octet-stream' \
        -H 'Content-Type: application/json' \
        -d @exported-rules.json
       ```
  </Accordion>

  <Accordion title="Use the Analytics Screen in the Rules Editor">
    This article describes how to use the Analytics screen in the Rules Editor.

    <Check>The Analytics screen was renamed from the Dashboard screen in Fusion 5.2.0. All functionality remained the same.</Check>

    ### UI elements

    #### Data date range

    * **Quick Range Selectors.** Click one of the quick range selectors to facet your data.

          <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-date.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=ba2e682955eff2420ae49b54ab786f3c" alt="Data date range selectors" width="927" height="117" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-date.png" />
    * **Calendar Selector.** Use the calendar selector to specify a start and end date and time facet for your data.

          <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-date-calendar.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=5452da040facd2f8ebaa38a2faa84b1f" alt="Calendar selector" width="559" height="618" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-date-calendar.png" />

    #### Visitor data

    * **Data Cards**

          <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-visitor-cards.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=b3f43504286aaad9934106ec26125f4c" alt="Data cards" width="2319" height="369" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-visitor-cards.png" />

      * **Site Visits.** The total number of visits.
      * **Total Searches.** The total number of searches performed.
      * **Unique Visitors.** The number of unique visitors to your site.
      * **Average Session.** The average length of time spent on your site.
    * **Data Graph.** Detailed information for the selected data card.

          <img src="https://mintcdn.com/lucidworks/1FfsxYVDR4XL56q9/assets/images/5.1/ai-rules/ui/rules-ui-dashboard-visitor-graph.png?fit=max&auto=format&n=1FfsxYVDR4XL56q9&q=85&s=f195437a3c20aeba43e26c1e4c3d7786" alt="Data graph" width="2318" height="672" data-path="assets/images/5.1/ai-rules/ui/rules-ui-dashboard-visitor-graph.png" />

    ## View data by date range

    The Rules Editor analytics allows you to view data by a date range. To do this, you can either:

    * Click one of the date range presets:

          <img src="https://mintcdn.com/lucidworks/TTnHmbCCHl-1HFoG/assets/images/5.1/ai-rules/date-range-presets.png?fit=max&auto=format&n=TTnHmbCCHl-1HFoG&q=85&s=c9972796555f38ee83888bcb2f4c5098" alt="Date range by preset" width="1026" height="156" data-path="assets/images/5.1/ai-rules/date-range-presets.png" />
    * Click the date range details to display and select your range on the calendar that appears:

          <img src="https://mintcdn.com/lucidworks/TTnHmbCCHl-1HFoG/assets/images/5.1/ai-rules/date-range-calendar.png?fit=max&auto=format&n=TTnHmbCCHl-1HFoG&q=85&s=af256a6109a4a9f3139ea133dd2e30c0" alt="Date range by calendar" width="1220" height="876" data-path="assets/images/5.1/ai-rules/date-range-calendar.png" />

    ## View additional card details

    Click one of the analytics cards to view additional details for that card’s data.
  </Accordion>
</AccordionGroup>
