> For the complete documentation index, see [llms.txt](https://dnotifier.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dnotifier.gitbook.io/product-docs/ai/semantic-search.md).

# Semantic search

**Semantic search** finds knowledge-base chunks whose meaning is closest to your query — not just keyword matches. Use `search` before composing a custom prompt, or rely on `useKnowledgeBase: true` in `sendAI` for automatic retrieval.

## Method

```
search({
  senderId: string,
  query: string,
  limit?: number,
  minSimilarity?: number,    // 0.0 – 1.0
  filterbySource?: string,   // matches metadata.source
})
```

| Parameter        | Description                                    |
| ---------------- | ---------------------------------------------- |
| `query`          | Natural-language question or keywords          |
| `limit`          | Max results (default server-side)              |
| `minSimilarity`  | Drop hits below this score                     |
| `filterbySource` | Filter by `metadata.source` from `addDocument` |

{% hint style="info" %}
Use **`transport: "http"`**. `search` returns ranked hits directly from the async call.
{% endhint %}

## Search vs `useKnowledgeBase`

| Approach                     | Control                           | Complexity                                                                 |
| ---------------------------- | --------------------------------- | -------------------------------------------------------------------------- |
| **`search` then `sendAI`**   | You choose which chunks to inject | Higher — custom prompts                                                    |
| **`useKnowledgeBase: true`** | Platform retrieves automatically  | Lower — see [Chat-style messages](/product-docs/ai/chat-style-messages.md) |

## Tuning tips

| Goal                  | Suggestion                                      |
| --------------------- | ----------------------------------------------- |
| Fewer false positives | Raise `minSimilarity` (e.g. `0.7`)              |
| Broader recall        | Lower `minSimilarity` (e.g. `0.3`)              |
| Scoped search         | Set `filterbySource` matching `metadata.source` |
| Debug empty results   | Verify documents exist via `listDocuments`      |

## Language guides

| Language                | Guide                                                                                 |
| ----------------------- | ------------------------------------------------------------------------------------- |
| JavaScript / TypeScript | [javascript-typescript.md](/product-docs/ai/semantic-search/javascript-typescript.md) |
| Dart / Flutter          | [dart-flutter.md](/product-docs/ai/semantic-search/dart-flutter.md)                   |

## Next steps

* [**Manage documents**](/product-docs/ai/manage-documents.md) — Index content first
* [**Example: RAG bot**](/product-docs/ai/example-rag-bot.md) — End-to-end Q\&A
