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

# Search Knowledge Base

> Configure a workflow step that runs a semantic, keyword, or hybrid search against an existing knowledge base and stores the results

Use **Search Knowledge Base** when you want a workflow step to query one of your knowledge bases and pass the matching chunks to later steps — for example, feeding retrieved context into an AI Prompt step.

## Configuration

| Option              | Required | Description                                                                                                                                          |
| ------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| Name                | No       | Label for the step in the workflow canvas.                                                                                                           |
| Knowledge Base      | Yes      | The knowledge base to search, selected in **Knowledge Base**.                                                                                        |
| Search Query        | Yes      | The query string. This field supports workflow variables through **Insert Variable**.                                                                |
| Search Type         | No       | One of **Hybrid**, **Semantic**, or **Keyword**. Defaults to **Hybrid**.                                                                             |
| Result Limit        | No       | Maximum number of matching chunks to return (1–20, default 5).                                                                                       |
| Score Threshold     | No       | Minimum relevance score required to include a result (0.0–1.0, default 0.0). A value of 0.0 returns all results up to the limit regardless of score. |
| When the step fails | No       | Controls whether the workflow should **Terminate Workflow** or **Continue** if this step fails.                                                      |

### Search Type

* **Hybrid** — Combines vector similarity and keyword matching. Recommended for most queries.
* **Semantic** — Pure vector similarity search. Best for conceptual or natural-language queries.
* **Keyword** — Full-text keyword search. Best for exact-match or structured queries.

### Result Limit

Controls how many chunks are returned. Higher limits increase context available to downstream steps but may also increase noise. The slider accepts values from 1 to 20.

### Score Threshold

Filters out low-relevance results. Raise this value (toward 1.0) to return only highly confident matches. Leave it at 0.0 to return all results up to the limit.

## Output

This step returns the matching chunks from the knowledge base:

```json theme={null}
[
  {
    "content": "...",
    "score": 0.87,
    "metadata": { ... }
  },
  ...
]
```

Reference the full result set in a later step:

```text theme={null}
{{step_2.output}}
```

A common pattern is to pass the output directly into an AI Prompt step as context:

```text theme={null}
Answer the following question using only the context below.

Context:
{{step_2.output}}

Question: {{start.query}}
```

## Cost

Each run of this step costs **1 task**.

## Example

Add **Search Knowledge Base** from the **Knowledge Base** group in **Search steps...**.

Set **Knowledge Base** to the knowledge base you want to query.

Enter the user's question in **Search Query**, or insert a variable from a start input: `{{start.question}}`.

Leave **Search Type** as **Hybrid** unless you have a specific reason to prefer pure semantic or keyword search.

Adjust **Result Limit** to control how many chunks are returned. Start with 5 and increase if answers seem incomplete.

Set **Score Threshold** to 0.5 or higher if you want to exclude low-confidence matches.

Click **Run** in the step header to test the search. Review the returned chunks in **Output**, then connect the output to an AI Prompt step to generate an answer.

{/* Add screenshot: Search Knowledge Base settings showing result limit and score threshold sliders */}

## Notes

* The effective search type falls back to the knowledge base's own default if the step setting is left at its default value.
* Score values are normalised to the 0–1 range. The exact meaning depends on the underlying embedding model and search backend.
* Search queries and results are logged as knowledge base search audit records for monitoring.

See also: [Write to Knowledge Base](./write-knowledge-base), [AI Prompt](../ai/ai-prompt), [Creating and Editing](../../creating-and-editing), [Testing and Iteration](../../testing-and-iteration), and [Error Handling](../../error-handling)
