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

# Rewrite Result • Rust AI Agent SDK

> RewriteResult: Result of query rewriting

# RewriteResult

> Defined in the [**Specialized Agents**](../modules/specialized_agents) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

Result of query rewriting

## Fields

| Name                    | Type                              | Description                                 |
| ----------------------- | --------------------------------- | ------------------------------------------- |
| `original_query`        | `String`                          | Original query                              |
| `rewritten_queries`     | `Vec&lt;String&gt;`               | Rewritten queries                           |
| `strategy_used`         | `RewriteStrategy`                 | Strategy used                               |
| `hypothetical_document` | `Option&lt;String&gt;`            | Hypothetical document (for HyDE strategy)   |
| `step_back_question`    | `Option&lt;String&gt;`            | Step-back question (for step-back strategy) |
| `sub_queries`           | `Option&lt;Vec&lt;String&gt;&gt;` | Sub-queries (for sub-queries strategy)      |
| `metadata`              | `HashMap&lt;String`               | Additional metadata                         |
| `serde_json`            | `:Value&gt;`                      | Additional metadata                         |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new(
        original: impl Into<String>,
        rewritten: Vec<String>,
        strategy: RewriteStrategy,
    ) -> Self
```

Create a new rewrite result

**Parameters:**

| Name        | Type                      |
| ----------- | ------------------------- |
| `original`  | `impl Into&lt;String&gt;` |
| `rewritten` | `Vec&lt;String&gt;`       |
| `strategy`  | `RewriteStrategy`         |

### `with_hypothetical_document`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn with_hypothetical_document(mut self, doc: impl Into<String>) -> Self
```

Set hypothetical document

**Parameters:**

| Name  | Type                      |
| ----- | ------------------------- |
| `doc` | `impl Into&lt;String&gt;` |

### `with_step_back_question`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn with_step_back_question(mut self, question: impl Into<String>) -> Self
```

Set step-back question

**Parameters:**

| Name       | Type                      |
| ---------- | ------------------------- |
| `question` | `impl Into&lt;String&gt;` |

### `with_sub_queries`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn with_sub_queries(mut self, queries: Vec<String>) -> Self
```

Set sub-queries

**Parameters:**

| Name      | Type                |
| --------- | ------------------- |
| `queries` | `Vec&lt;String&gt;` |

### `with_metadata`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn with_metadata(mut self, key: impl Into<String>, value: impl Into<serde_json::Value>) -> Self
```

Add metadata

**Parameters:**

| Name    | Type                                 |
| ------- | ------------------------------------ |
| `key`   | `impl Into&lt;String&gt;`            |
| `value` | `impl Into&lt;serde_json::Value&gt;` |

### `primary_query`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn primary_query(&self) -> Option<&str>
```

Get the primary rewritten query

### `all_queries`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn all_queries(&self) -> Vec<&str>
```

Get all queries for retrieval

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/specialized_agents.rs#L457">
  `praisonai/src/specialized_agents.rs` at line 457
</Card>
