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

# Response rewriting

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>;
};

[localhost link]: http://localhost:3000/docs/lucidworks-search/07-improve-your-queries/response-rewriting/overview

[mintlify link]: https://doc.lucidworks.com/docs/lucidworks-search/07-improve-your-queries/response-rewriting/overview

[old doc.lw link]: https://doc.lucidworks.com/managed-fusion/5.9/tsjj9g

Response rewriting is a strategy for improving relevancy using AI-generated data by modifying Solr’s response before passing it to the search application. There are two approaches to configuring response rewriting:

<LwTemplate />

## Rules

Any [rule type](/docs/lucidworks-search/07-improve-your-queries/query-rewriting/overview) can add content to the response by modifying the `responseValues` field. These two rule types can replace the whole response:

* Banner\
  Display a user-defined banner message when the rule fires.
* Redirect\
  Send users to a different URL instead of the search results.

For more information, see [Query rewriting business rules](/docs/lucidworks-search/07-improve-your-queries/query-rewriting/overview) section.

## Query pipeline stages

Query pipeline stages that perform response rewriting must appear **after** the [Solr Query stage](/docs/lucidworks-search/09-developer-documentation/config-specs/query-pipeline-stages/solr-query). These stages fall into two categories:

* **Stages that act on the whole set of results**

  * [Response Shuffle stage](/docs/lucidworks-search/09-developer-documentation/config-specs/query-pipeline-stages/response-shuffle)\
    "De-bias" results by shuffling the top N results randomly.

  * [Response Pairwise Swap stage](/docs/lucidworks-search/09-developer-documentation/config-specs/query-pipeline-stages/response-pairwise-swap)\
    "De-bias" results by swapping the search results at any two positions, such as positions 1 and 2, positions 3 and 4, and so on.

* **Stages that act on individual documents**

  * [Response Document Exclusion stage](/docs/lucidworks-search/09-developer-documentation/config-specs/query-pipeline-stages/response-document-exclusion)\
    Drop all documents that match all of the specified rules.

  * [Modify Response with Rules stage](/docs/lucidworks-search/09-developer-documentation/config-specs/query-pipeline-stages/modify-response-rules)\
    Apply [rules](/docs/lucidworks-search/07-improve-your-queries/business-rules/overview) to the response.
