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

# Search Rewrites

> Predictive Merchandiser

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/curating-your-search-experience/predictive-merchandiser/search-rewrites

[mintlify link]: https://doc.lucidworks.com/docs/5/fusion/getting-data-out/curating-your-search-experience/predictive-merchandiser/search-rewrites

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

Search rewriting is a way of modifying search queries so that they more accurately reflect the intentions of your customers. You can create a misspelling search rewrite, for example, to correct a spelling mistake that commonly occurs when searching for a particular product. The misspelled query will then produce the same results as a correctly spelled search.

There are four rewrite types:

* **Head/Tail** - improves poorly performing searches.
* **Misspelling detection** - corrects common spelling mistakes.
* **Phrase detection** - identifies products with matching phrases.
* **Synonym detection** - includes alternative words with the same meaning.

<Accordion title="Use Predictive Merchandiser Query Rewrites">
  You can create query rewrite rules in Predictive Merchandiser. This is similar to using the Rules Editor to create query rewrite rules, except there are additional options in Predictive Merchandiser.

  1. In Fusion, navigate to **Relevance** > **Rules** > **Merchandiser**.
  2. Enter a search term or phrase in the search bar.
  3. Click **Start Task**.
  4. Hover your cursor next to the query. A **+** button will appear: <InlineImage src="/assets/images/predictive-merchandiser/buttons/query-rewrite-add-button.png" alt="Add query rewrite" />
  5. Click the **+** button. A list of query rewrites options will appear: [Head/Tail](#head-tail), [Misspelling](#misspelling), [Phrase](#phrase), [Synonym](#synonym), and [Remove Words](#remove-words).

  <LwTemplate />

  ## Head/Tail

  You can create a Head/Tail rewrite to improve search results using methods other than correcting for misspellings or synonym expansion. When a poorly defined search term is identified, the original term is replaced by an improved search term.

  For example, a search for `iphone case yellow` could be improved by using the search term `iphone case yellow +color:"yellow"` (in this case making use of the color field in the data).

  Most Head/Tail rewrites are typically created automatically via machine learning. However, if desired, custom rewrites can be manually created using the following steps.

  1. From the list of query rewrite options, select **Head/Tail**. A form will appear:

       <img src="https://mintcdn.com/lucidworks/3Ch7Gf3ey98GnjMH/assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-headtail.png?fit=max&auto=format&n=3Ch7Gf3ey98GnjMH&q=85&s=766713db1094bd68e4d5d4f2140e46a9" alt="Create head/tail query rewrite" width="310" height="457" data-path="assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-headtail.png" />

     This form contains the following fields:

     |                |                                                                            |                                      |
     | -------------- | -------------------------------------------------------------------------- | ------------------------------------ |
     | Parameter      | Description                                                                | Example Value                        |
     | Tail Query     | The tail query itself.                                                     | `iphone case yellow`                 |
     | Improved Query | The query that will replace the tail query phrase.                         | `iphone case yellow +color:"yellow"` |
     | Tags           | Optional metadata tags that can be used to identify and organize rewrites. | `blackfridaysale`                    |
  2. Enter one or more improved search terms in the **Improved Query** field.
  3. Click the **Save** button.

  The search is re-run using the improved search term, and a Search box information panel drops down to show that the new query rewrite has fired:

  <img src="https://mintcdn.com/lucidworks/3Ch7Gf3ey98GnjMH/assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-headtail-results.png?fit=max&auto=format&n=3Ch7Gf3ey98GnjMH&q=85&s=d52f86259e74f4f377f3e1cae7309dd4" alt="Head/tail rewrite results" style={{ width: "450px" }} width="911" height="294" data-path="assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-headtail-results.png" />

  ## Misspelling

  You can create a misspelling query rewrite to detect and correct common spelling mistakes. When a customer enters a search term containing a known misspelling, the incorrect spelling is replaced with the spelling correction.

  For example, if your customers frequently misspell or mistype the word `sweater` as `sweatre`, you can set up a query rewrite to automatically correct it.

  1. From the list of query rewrite options, select **Misspelling**. A form will appear:

       <img src="https://mintcdn.com/lucidworks/3Ch7Gf3ey98GnjMH/assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-misspelling.png?fit=max&auto=format&n=3Ch7Gf3ey98GnjMH&q=85&s=45647e54115f627ed3acbe0c1c6387be" alt="Create misspelling query rewrite" width="313" height="513" data-path="assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-misspelling.png" />

     This form contains the following fields:

     |                 |                                                                                                                                                                                                                                 |                   |
     | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- |
     | Parameter       | Description                                                                                                                                                                                                                     | Example Value     |
     | Misspelled Term | The phrase itself.                                                                                                                                                                                                              | `sweatre`         |
     | Corrected Term  | The term that will replace the misspelled term.                                                                                                                                                                                 | `sweater`         |
     | Action          | Action to perform.                                                                                                                                                                                                              |                   |
     | Confidence      | Confidence score from the phrase job. A confidence level of `1` represents 100% confidence. For rules created automatically via machine learning, the confidence level will reflect the output from the machine learning model. | `1`               |
     | Tags            | Optional metadata tags that can be used to identify and organize rewrites.                                                                                                                                                      | `blackfridaysale` |
  2. Enter one or more spelling corrections in the **Corrected Term** field.
  3. Click the **Save** button.

  The search is re-run using the corrected spelling, and a Search box information panel drops down to show that the new query rewrite has fired:

  <img src="https://mintcdn.com/lucidworks/3Ch7Gf3ey98GnjMH/assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-misspelling-results.png?fit=max&auto=format&n=3Ch7Gf3ey98GnjMH&q=85&s=d3146efa0f6f8633b3f2ef23a48135d8" alt="Misspelling rewrite results" style={{ width: "450px" }} width="921" height="288" data-path="assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-misspelling-results.png" />

  ## Phrase

  You can use query rewriting to identify phrases used in search terms so that products with matching phrases are boosted in the search results. This is helpful when users do not use quotation marks to identify phrases in their search terms.

  For example, without phrase detection a search for the words `remote control` would show results for both `remote` and `control`. With phrase detection, this search would correctly boost results for `"remote control"`.

  1. From the list of query rewrite options, select **Phrase**. A form will appear:

       <img src="https://mintcdn.com/lucidworks/3Ch7Gf3ey98GnjMH/assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-phrase.png?fit=max&auto=format&n=3Ch7Gf3ey98GnjMH&q=85&s=cd9f981bf05f465caeaa1dab0435d31d" alt="Create phrase query rewrite" width="313" height="542" data-path="assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-phrase.png" />

     This form contains the following fields:

     |              |                                                                                                                                                                                                                                 |                   |
     | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- |
     | Parameter    | Description                                                                                                                                                                                                                     | Example Value     |
     | Surface Form | The phrase itself.                                                                                                                                                                                                              | `remote control`  |
     | Word Count   | Indicates how many words are included in the phrase.                                                                                                                                                                            | `2`               |
     | Confidence   | Confidence score from the phrase job. A confidence level of `1` represents 100% confidence. For rules created automatically via machine learning, the confidence level will reflect the output from the machine learning model. | `1`               |
     | Tags         | Optional metadata tags that can be used to identify and organize rewrites.                                                                                                                                                      | `blackfridaysale` |
     | Phrase Count | Denotes how many times this phrase was found in the source. This value is automatically set via machine learning. It does not need to be set manually.                                                                          | `5`               |
     | Boost Factor | The factor to use to boost this phrase in matching queries.                                                                                                                                                                     | `2.0`             |
     | Slop Factor  | Phrase slop, or the distance between the terms of the query while still considering it a phrase match.                                                                                                                          | `10`              |
  2. Enter the number of words in the phrase in the **Word Count** field.
  3. Click the **Save** button.

  The search is re-run, with your search words identified as a phrase, and a Search box information panel drops down to show that the new query rewrite has fired:

  <img src="https://mintcdn.com/lucidworks/3Ch7Gf3ey98GnjMH/assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-phrase-results.png?fit=max&auto=format&n=3Ch7Gf3ey98GnjMH&q=85&s=5786021aa51fe3a6594518146e807c78" alt="Phrase rewrite results" style={{ width: "450px" }} width="910" height="268" data-path="assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-phrase-results.png" />

  ## Synonym

  You can specify synonyms for a specified search term so that alternative words with the same meaning are automatically used in the search query. When a customer enters a search term with a synonym match, the alternative words are used instead of, or in addition to, the original search term.

  For example, the search term `sweater` could have the synonyms `pullover` and `jumper`.

  1. From the list of query rewrite options, select **Synonym**. A form will appear:

       <img src="https://mintcdn.com/lucidworks/3Ch7Gf3ey98GnjMH/assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-synonym.png?fit=max&auto=format&n=3Ch7Gf3ey98GnjMH&q=85&s=e4dd9b81f377ea282997dabb1ec02167" alt="Create synonym query rewrite" width="311" height="542" data-path="assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-synonym.png" />

     This form contains the following fields:

     |                  |                                                                                                                                                                                                                                                                                                                                                                                                                                           |                      |
     | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- |
     | Parameter        | Description                                                                                                                                                                                                                                                                                                                                                                                                                               | Example Value        |
     | Surface Form     | The term that has synonyms.                                                                                                                                                                                                                                                                                                                                                                                                               | `sweater`            |
     | Direction        | With a **oneway** search, the original search term is replaced by the synonym. In the example above, `sweater` would be replaced by the alternative words `pullover` and `jumper`. With a **symmetric** search, the search query is expanded to include the original term and the synonyms, resulting in a greater number of potential hits. In the example above, this time the query would include `sweater`, `pullover`, and `jumper`. | `symmetric`          |
     | Synonym Mappings | Synonyms for the surface form.                                                                                                                                                                                                                                                                                                                                                                                                            | `pullover`, `jumper` |
     | Confidence       | Confidence score from the phrase job. A confidence level of `1` represents 100% confidence. For rules created automatically via machine learning, the confidence level will reflect the output from the machine learning model.                                                                                                                                                                                                           | `1`                  |
     | Tags             | Optional metadata tags that can be used to identify and organize rewrites.                                                                                                                                                                                                                                                                                                                                                                | `blackfridaysale`    |
     | Count            | How many times this term occurred in the signal data when it was discovered. This value is optional when a rewrite is being defined manually.                                                                                                                                                                                                                                                                                             | `5`                  |
  2. Choose whether the direction is **oneway** or **symmetric**.
  3. Enter one or more alternative words in the **Synonym Mappings** field.
  4. Click the **Save** button.

  The search is re-run using the synonyms, and a Search box information panel drops down to show that the new query rewrite has fired:

  <img src="https://mintcdn.com/lucidworks/3Ch7Gf3ey98GnjMH/assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-synonym-results.png?fit=max&auto=format&n=3Ch7Gf3ey98GnjMH&q=85&s=749eaa9ee366affcb177e37867df8f47" alt="Synonym rewrite results" style={{ width: "450px" }} width="912" height="272" data-path="assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-synonym-results.png" />

  ## Remove Words

  <Note>The Remove Words feature is available in Fusion 5.4 and later.</Note>

  You can create a Remove Words query rewrite to remove words from a query. This query rewrite is helpful when a word in the search query does not add value to the search results.

  For example, you can rewrite a search query for `case study examples` to remove `examples` and then display results for `case study`.

  1. From the list of query rewrite options, select Remove Words. A form appears:

       <img src="https://mintcdn.com/lucidworks/3Ch7Gf3ey98GnjMH/assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-remove-words.png?fit=max&auto=format&n=3Ch7Gf3ey98GnjMH&q=85&s=ad0b2acc3641486611b10b222795af43" alt="Create synonym query rewrite" width="312" height="303" data-path="assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-remove-words.png" />

     This form contains the following fields:

     |                  |                                                                                                                                                                                                                   |                       |
     | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
     | Parameter        | Description                                                                                                                                                                                                       | Example Value         |
     | Phrase to remove | The words to remove from the trigger phrase.                                                                                                                                                                      | `examples`            |
     | Trigger phrases  | The query that prompts the removal of the phrase. The trigger phrase is not necessarily a complete query. If the query contains the trigger phrase, then Fusion removes the phrase in the Phrase to Remove field. | `case study examples` |
  2. Enter a phrase to remove and a trigger phrase. Note that the phrase to remove is auto-populated with the query.
  3. Click **Save**.

  The search is re-run, and a Search box information panel drops down to show that the new query rewrite has fired:

  <img src="https://mintcdn.com/lucidworks/3Ch7Gf3ey98GnjMH/assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-remove-words-results.png?fit=max&auto=format&n=3Ch7Gf3ey98GnjMH&q=85&s=b742894a866fd42d01bdaf26777482b2" alt="Remove words rewrite results" style={{ width: "450px" }} width="908" height="282" data-path="assets/images/predictive-merchandiser/screenshots/pm-query-rewrite-remove-words-results.png" />

  ## Learn more

  <Card title="Predictive Merchandiser: Rewrites Manager" class="note-image" href="https://academy.lucidworks.com/pm-rewrites-manager" cta="Take this course on the LucidAcademy." icon="graduation-cap" iconType="duotone">
    The course for **Predictive Merchandiser: Rewrites Manager** focuses on using search rewrites to boost conversions and create better customer experiences by improving your relevancy.
  </Card>
</Accordion>

In Predictive Merchandiser you can create search rewrites manually. You can also edit, test, review and publish the search rewrites that are generated automatically in Fusion from signals data.

<Card title="Predictive Merchandiser: Rewrites Manager" class="note-image" href="https://academy.lucidworks.com/predictive-merchandiser-rewrites-manager" cta="Take this course on the LucidAcademy." icon="graduation-cap" iconType="duotone">
  The course for **Predictive Merchandiser: Rewrites Manager** focuses on using search rewrites to boost conversions and create better customer experiences by improving your relevancy.
</Card>
