# Knowledge retrieval Node

### Overview

The Knowledge Retrieval Node searches and retrieves relevant documents from your knowledge collections based on a query. It supports semantic search through vector embeddings and allows filtering of results using vector store-specific filtering syntax. Each knowledge collection can be configured with different vector stores (Milvus, Qdrant, Chroma, Pinecone, ...).

Usage cost: 0.1 credit / document

### Configuration

#### Settings

1. **Collection Selection**
   * Collection\*: Select the knowledge collection to search
   * Number of Documents: Number of results to return (default: 5)
   * Query\*: Search query used to find relevant documents
   * Filtering: Optional filtering condition based on metadata

#### Output Ports

* `knowledges` (Document\[]): Retrieved documents with full metadata
* `documents_content` (string\[]): Array of document contents only

### Filtering example depending on vector store

**Milvus/Zilliz**

```sql
metadata["field"] == "value"
```

**Qdrant**

```json
{
  "must": [
    {"key": "metadata.field", "match": {"value": "exact_match"}}
  ]
}
```

**Chroma**

```json
{
  "field": {"$eq": "value"}
}
```

**Pinecone**

```json
{
  "field": {"$eq": "value"}
}
```

### Best Practices

1. **Query Construction**
   * Keep queries clear and focused
   * Include key terms relevant to desired content
   * Consider semantic meaning rather than exact keywords
   * Test queries with different phrasings
2. **Result Optimization**
   * Adjust number of documents based on use case
   * Use filtering to narrow down results, or to built multi-tenant data retrieval
   * Consider document length when setting limits
3. **Filtering Usage**
   * Follow vector store-specific syntax
   * Test filters with sample data
   * Use appropriate operators for data types

For vector store specific filter syntax, refer to:

* Milvus: [Filtering Documentation](https://milvus.io/docs/boolean.md)
* Zilliz: [Filtering Documentation](https://docs.zilliz.com/docs/filtering)
* Qdrant: [Filtering Documentation](https://qdrant.tech/documentation/concepts/filtering/)
* Chroma: [Where Filters Documentation](https://docs.trychroma.com/docs/querying-collections/metadata-filtering)
* Pinecone: [Metadata Filtering Guide](https://docs.pinecone.io/guides/data/filter-with-metadata#metadata-query-language)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.waterflai.ai/studio/studio-builders/flow-components-nodes/knowledge-retrieval-node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
