---
title: "Search knowledge base"
method: POST
path: "/v2/knowledge/{knowledge_id}/search"
tags: ["Knowledge Bases"]
---

# Search knowledge base

`POST /v2/knowledge/{knowledge_id}/search`

Search a Knowledge Base and return the most similar chunks, along with their search and rerank scores. Note that all configuration changes made in the API will override the settings in the UI.

## Path parameters

- `knowledge_id` string, required — The unique identifier or key of the knowledge base

## Request body

- object
  - `query` string, required — The query to use to search the knowledge base
  - `top_k` integer — The number of results to return. If not provided, will default to the knowledge base configured `top_k`.
  - `threshold` number — The threshold to apply to the search. If not provided, will default to the knowledge base configured `threshold`
  - `search_type` 'vector_search' | 'keyword_search' | 'hybrid_search' — The type of search to perform. If not provided, will default to the knowledge base configured `retrieval_type`
  - `filter_by` union — The metadata filter to apply to the search. Check the [Searching a Knowledge Base](https://docs.orq.ai/docs/knowledge/api#knowledge-base-search) for more information.
    - object
    - object — And
      - `and` object[], required
    - object — Or
      - `or` object[], required
  - `search_options` object — Additional search options
    - `include_vectors` boolean — Whether to include the vector in the chunk
    - `include_metadata` boolean — Whether to include the metadata in the chunk
    - `include_scores` boolean — Whether to include the scores in the chunk
  - `rerank_config` object — Override the rerank configuration for this search. If not provided, will use the knowledge base configured rerank settings.
    - `model` string, required — The name of the rerank model to use. Refer to the [model list](https://docs.orq.ai/docs/proxy#/rerank-models).
    - `threshold` number — The threshold value used to filter the rerank results, only documents with a relevance score greater than the threshold will be returned
    - `top_k` integer — The number of top results to return after reranking. If not provided, will default to the knowledge base configured `top_k`.
  - `agentic_rag_config` object — Override the agentic RAG configuration for this search. If not provided, will use the knowledge base configured agentic RAG settings.
    - `model` string, required — The name of the model for the Agent to use. Refer to the [model list](https://docs.orq.ai/docs/proxy#/chat-models).

## Response `200`

Search knowledge base

- object
  - `matches` object[], required
    - `id` string, required
    - `text` string, required
    - `vector` number[]
    - `metadata` object
    - `scores` object
      - `rerank_score` number
      - `search_score` number

---

[API](https://skmtc.net/orq-ai/apis/orq-ai-api.md) · [All operations](https://skmtc.net/orq-ai/apis/orq-ai-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/orq-ai/orq-ai-api/versions/6a22c53a2580/schema)
