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

# Synonym Detection

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/4/fusion-ai/concepts/query-rewriting/synonym-detection

[mintlify link]: https://doc.lucidworks.com/docs/4/fusion-ai/concepts/query-rewriting/synonym-detection

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

The Synonym Detection feature generates pairs of synonyms and pairs of similar queries. Two words are considered potential synonyms when they are used in a similar context in similar queries. When synonym detection is enabled, a query that contains a matching term is expanded to include all of its synonyms, with the original term boosted by a factor of two.

Synonyms are applied in the [Text Tagger stage](/docs/4/fusion-server/reference/pipeline-stages/query/text-tagger-query-stage) of the query pipeline.

The [Synonym and Similar Queries Detection job](/docs/4/fusion-ai/reference/jobs/synonym-and-similar-queries-detection) automatically creates synonym pairs based on your AI-generated data.

When you navigate to **Relevance** > **Rules**, the application displays the **Query Rewriting** screen. Select **Synonym Detection**. The application displays the **Synonym Detection** screen.

<Accordion title="Use Synonym Detection">
  <Card title="Query Analytics" class="note-image" href="https://academy.lucidworks.com/query-analytics" cta="Take this course on the LucidAcademy." icon="graduation-cap" iconType="duotone">
    The course for **Query Analytics** focuses on how Fusion provides query analytics to detect and improve underperforming queries.
  </Card>

  <LwTemplate />

  ## Reviewing auto-generated synonym pairs

  Synonyms that are automatically generated by the [Synonym and Similar Queries Detection job](/docs/4/fusion-ai/reference/jobs/synonym-and-similar-queries-detection) are assigned the following status value:

  * **Pending**

    The confidence level is ambiguous, and the result must be reviewed by a user before it can be deployed.  It will only be moved from the `_query_rewrite_staging` collection to the `_query_rewrite` collection when its status has changed to "Approved" *and* it has been published.

    <Note>  By default, all results from a synonym job are set to "Pending", since there are usually a limited number of synonyms, and synonym expansion can have high impact on relevancy.</Note>

  ### How to review a pending synonym pair result

  1. Navigate to **Relevance** > **Rules**. The application displays the **Query Rewriting** screen.
  2. Select **Synonym Detection**. The application displays the **Synonym Detection** screen.

     <Tip>Notice the **Status** facet on the left. Click **Pending** to view only the items that need review.</Tip>

  {/* // Currently this facet does not work (in the qrw-demo app). */}

  1. Click the <InlineImage src="/assets/images/4.2/icons/edit-rule.png" alt="Edit icon" /> icon next to the synonym pair.

  2. In the **Status** column, select either "Approved" or "Denied".

     Optionally, you can also edit the synonym pair itself.

     Where alternative synonyms were detected, you can click **Suggestions** to view and select them as replacements for the displayed synonym pair:

       <img src="https://mintcdn.com/lucidworks/vupE2UCZdg04NdXx/assets/images/4.2/rules-synonyms-suggestions.png?fit=max&auto=format&n=vupE2UCZdg04NdXx&q=85&s=f6088345cf8d5e9143c1603aead72031" alt="Synonym Suggestions" width="1794" height="1023" data-path="assets/images/4.2/rules-synonyms-suggestions.png" />

     <Tip>   Although the Confidence field is also editable, changing its value makes no difference.</Tip>

  3. Click the **Close** icon next to the updated synonym pair:

       <img src="https://mintcdn.com/lucidworks/vupE2UCZdg04NdXx/assets/images/4.2/rules-misspelling-close.png?fit=max&auto=format&n=vupE2UCZdg04NdXx&q=85&s=303fd5ee521213901106dd99b0b16a7a" alt="Close a synonym pair" width="445" height="434" data-path="assets/images/4.2/rules-misspelling-close.png" />

  <Note>Approving a synonym pair does not automatically deploy it to the `_query_rewrite` collection.  When you have finished your review, you must click **Publish** to deploy your changes.</Note>

  {/* // end::review[] */}

  {/* // tag::add-new[] */}

  ## Adding new synonym pairs

  You can manually add synonym pairs in addition to any generated by the [Synonym and Similar Queries Detection job](/docs/4/fusion-ai/reference/jobs/synonym-and-similar-queries-detection).

  ### How to add a synonym pair

  1. Navigate to **Relevance** > **Rules**. The application displays the **Query Rewriting** screen.
  2. Select **Synonym Detection**. The application displays the **Synonym Detection** screen.
  3. At the bottom of the rules list, click the <InlineImage src="/assets/images/4.2/icons/add-rule.png" alt="Add icon" /> icon.

     A new synonym pair appears at the top of the list:

       <img src="https://mintcdn.com/lucidworks/vupE2UCZdg04NdXx/assets/images/4.2/rules-synonym-add.png?fit=max&auto=format&n=vupE2UCZdg04NdXx&q=85&s=c168e200c4ab4a5883bdf669a7f131e0" alt="Add a synonym pair" width="2562" height="1284" data-path="assets/images/4.2/rules-synonym-add.png" />
  4. Enter the query term.
  5. Enter one or more synonym pairs.

     <Tip>   It is not necessary to set a confidence value.</Tip>
  6. Select the synonym pair’s status, depending on whether you want to deploy it the next time you publish your changes ("Approved") or save it for further review ("Pending").
  7. Click the check mark to save the new synonym pair:

       <img src="https://mintcdn.com/lucidworks/vupE2UCZdg04NdXx/assets/images/4.2/rules-synonym-save.png?fit=max&auto=format&n=vupE2UCZdg04NdXx&q=85&s=4d17c79b1473fa2bcb84373573d88fce" alt="Save a synonym pair" width="2562" height="1284" data-path="assets/images/4.2/rules-synonym-save.png" />

  {/* // end::add-new[] */}

  {/* // tag::publish[] */}

  ## Publishing your changes

  ### How to publish updated synonym pairs

  1. In the **Synonym Detection** screen, click the **PUBLISH** button.

     Fusion prompts you to confirm that you want to publish your changes.
  2. Click **PUBLISH**.

  {/* // Currently this does not update the count of unpublished changes. */}

  <Tip>You can un-publish a query rewrite by changing its status to "denied", then clicking **PUBLISH**.</Tip>

  {/* // I am assuming this is the case. */}

  {/* // end::publish[] */}
</Accordion>

When you manually add new synonym pairs, subsequent job runs use those documents as input for machine learning to improve the job’s output. Unlike job-generated documents, manually-added query rewriting documents are never overwritten by new job output.

<img src="https://mintcdn.com/lucidworks/vupE2UCZdg04NdXx/assets/images/4.2/rules-synonyms.png?fit=max&auto=format&n=vupE2UCZdg04NdXx&q=85&s=dc0f32004485c48bf19a6fafaf51db62" alt="Synonyms screen" width="2880" height="1524" data-path="assets/images/4.2/rules-synonyms.png" />

## Synonym directionality

When you edit or create a synonym pair, you can configure its directionality, either [uni-directional](#uni-directional-synonyms) or [bi-directional](#bi-directional-synonyms).

To toggle between uni-directional and bi-directional, click the <InlineImage src="/assets/images/4.2/icons/edit-rule.png" /> icon next to the synonym pair, then click the directionality icon:

<img src="https://mintcdn.com/lucidworks/vupE2UCZdg04NdXx/assets/images/4.2/rules-synonyms-toggle.png?fit=max&auto=format&n=vupE2UCZdg04NdXx&q=85&s=5ccdcefdf2642a30b9cdcaedf3a1b86e" alt="Directionality toggle" width="1432" height="292" data-path="assets/images/4.2/rules-synonyms-toggle.png" />

### Uni-directional synonyms

Uni-directional synonyms produce query substitutions. That is, when a query term matches a known uni-directional synonym, the original query term is replaced with the synonym.

In the uni-directional example below, "iphone" is a synonym of "phone" but "phone" is not a synonym of "iphone". When "phone" is found in a query, it is replaced with "iphone".

<img src="https://mintcdn.com/lucidworks/vupE2UCZdg04NdXx/assets/images/4.2/rules-synonym-unidirectional.png?fit=max&auto=format&n=vupE2UCZdg04NdXx&q=85&s=dcb8790ff804f63aabd33c17df181861" alt="Uni-directional synonyms" width="1308" height="165" data-path="assets/images/4.2/rules-synonym-unidirectional.png" />

<Tip>
  When you manually create a new synonym pair, the default is uni-directional.
</Tip>

### Bi-directional synonyms

Bi-directional synonyms produce *expanded* queries. That is, when a query contains a known bi-directional synonym, the query is rewritten to include the original term *plus* all of its known bi-directional synonyms, resulting in a greater number of potentially relevant results. The original term is also boosted to help preserve the user’s intent.

In the bi-directional example below, "tv" is a synonym of "television" *and* "television" is a synonym of "tv". If a query contains either "tv" or "television", the query is expanded to include both terms.

<img src="https://mintcdn.com/lucidworks/vupE2UCZdg04NdXx/assets/images/4.2/rules-synonym-bidirectional.png?fit=max&auto=format&n=vupE2UCZdg04NdXx&q=85&s=6557dc55a83981279555b51bd4a2ef7f" alt="Bi-directional synonyms" width="1450" height="166" data-path="assets/images/4.2/rules-synonym-bidirectional.png" />

<Tip>
  Job-generated synonyms are always bi-directional unless a reviewer edits them.
</Tip>
