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

# Search knowledge base

> 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.



## OpenAPI

````yaml post /v2/knowledge/{knowledge_id}/search
openapi: 3.1.0
info:
  title: orq.ai API
  version: '2.0'
  description: orq.ai API documentation
servers:
  - url: https://api.orq.ai
security:
  - ApiKey: []
tags:
  - name: Guardrail Rules
  - name: Policies
  - name: Routing Rules
  - name: Files
    description: File upload and retrieval operations.
  - name: FilesService
  - name: Projects
    description: Projects organize resources within a workspace
  - name: ProjectsService
  - name: Skills
    description: >-
      Skills are modular instructions you can use to codify processes and
      conventions
  - name: SkillsService
  - name: Responses
  - description: >-
      Run agents on a cadence — cron, interval, or one-off. Minimum firing
      interval is 1 hour.
    name: Agent Schedules
  - name: Reporting
    description: >-
      GenAI reporting API over canonical analytics rollups. Accepts a metric
      name, time range, grain, group-by, and filters; returns a typed time
      series and optional totals.
  - name: ReportingService
    description: |-
      ReportingService exposes a single QueryReport RPC that maps allowlisted
       analytics payloads onto safe rollup queries. Callers never send SQL;
       the backend picks the rollup family and grain from the metric
       catalogue, the requested range, and the requested grouping.
externalDocs:
  url: https://docs.orq.ai
  description: orq.ai Documentation
paths:
  /v2/knowledge/{knowledge_id}/search:
    post:
      tags:
        - Knowledge Bases
      summary: Search knowledge base
      description: >-
        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.
      operationId: SearchKnowledge
      parameters:
        - schema:
            type: string
            description: The unique identifier or key of the knowledge base
          required: true
          description: The unique identifier or key of the knowledge base
          name: knowledge_id
          in: path
      requestBody:
        description: A search request for chunks in a knowledge base
        content:
          application/json:
            schema:
              type: object
              properties:
                query:
                  type: string
                  description: The query to use to search the knowledge base
                top_k:
                  type: integer
                  minimum: 1
                  maximum: 100
                  description: >-
                    The number of results to return. If not provided, will
                    default to the knowledge base configured `top_k`.
                threshold:
                  type: number
                  minimum: 0
                  maximum: 1
                  description: >-
                    The threshold to apply to the search. If not provided, will
                    default to the knowledge base configured `threshold`
                search_type:
                  type: string
                  enum:
                    - vector_search
                    - keyword_search
                    - hybrid_search
                  default: hybrid_search
                  description: >-
                    The type of search to perform. If not provided, will default
                    to the knowledge base configured `retrieval_type`
                filter_by:
                  anyOf:
                    - type: object
                      additionalProperties:
                        anyOf:
                          - type: object
                            properties:
                              eq:
                                anyOf:
                                  - type: string
                                    title: string
                                    description: String
                                  - type: number
                                    title: number
                                    description: Number
                                  - type: boolean
                                    title: boolean
                                    description: Boolean
                            required:
                              - eq
                            title: eq
                            description: Equal to
                          - type: object
                            properties:
                              ne:
                                anyOf:
                                  - type: string
                                    title: string
                                    description: String
                                  - type: number
                                    title: number
                                    description: Number
                                  - type: boolean
                                    title: boolean
                                    description: Boolean
                            required:
                              - ne
                            title: ne
                            description: Not equal to
                          - type: object
                            properties:
                              gt:
                                type: number
                            required:
                              - gt
                            title: gt
                            description: Greater than
                          - type: object
                            properties:
                              gte:
                                type: number
                            required:
                              - gte
                            title: gte
                            description: Greater than or equal to
                          - type: object
                            properties:
                              lt:
                                type: number
                            required:
                              - lt
                            title: lt
                            description: Less than
                          - type: object
                            properties:
                              lte:
                                type: number
                            required:
                              - lte
                            title: lte
                            description: Less than or equal to
                          - type: object
                            properties:
                              in:
                                type: array
                                items:
                                  anyOf:
                                    - type: string
                                      title: string
                                      description: String
                                    - type: number
                                      title: number
                                      description: Number
                                    - type: boolean
                                      title: boolean
                                      description: Boolean
                            required:
                              - in
                            title: in
                            description: In
                          - type: object
                            properties:
                              nin:
                                type: array
                                items:
                                  anyOf:
                                    - type: string
                                      title: string
                                      description: String
                                    - type: number
                                      title: number
                                      description: Number
                                    - type: boolean
                                      title: boolean
                                      description: Boolean
                            required:
                              - nin
                            title: nin
                            description: Not in
                          - type: object
                            properties:
                              exists:
                                type: boolean
                            required:
                              - exists
                            title: exists
                            description: Exists
                      title: Search operator
                    - type: object
                      properties:
                        and:
                          type: array
                          items:
                            type: object
                            additionalProperties:
                              anyOf:
                                - type: object
                                  properties:
                                    eq:
                                      anyOf:
                                        - type: string
                                          title: string
                                          description: String
                                        - type: number
                                          title: number
                                          description: Number
                                        - type: boolean
                                          title: boolean
                                          description: Boolean
                                  required:
                                    - eq
                                  title: eq
                                  description: Equal to
                                - type: object
                                  properties:
                                    ne:
                                      anyOf:
                                        - type: string
                                          title: string
                                          description: String
                                        - type: number
                                          title: number
                                          description: Number
                                        - type: boolean
                                          title: boolean
                                          description: Boolean
                                  required:
                                    - ne
                                  title: ne
                                  description: Not equal to
                                - type: object
                                  properties:
                                    gt:
                                      type: number
                                  required:
                                    - gt
                                  title: gt
                                  description: Greater than
                                - type: object
                                  properties:
                                    gte:
                                      type: number
                                  required:
                                    - gte
                                  title: gte
                                  description: Greater than or equal to
                                - type: object
                                  properties:
                                    lt:
                                      type: number
                                  required:
                                    - lt
                                  title: lt
                                  description: Less than
                                - type: object
                                  properties:
                                    lte:
                                      type: number
                                  required:
                                    - lte
                                  title: lte
                                  description: Less than or equal to
                                - type: object
                                  properties:
                                    in:
                                      type: array
                                      items:
                                        anyOf:
                                          - type: string
                                            title: string
                                            description: String
                                          - type: number
                                            title: number
                                            description: Number
                                          - type: boolean
                                            title: boolean
                                            description: Boolean
                                  required:
                                    - in
                                  title: in
                                  description: In
                                - type: object
                                  properties:
                                    nin:
                                      type: array
                                      items:
                                        anyOf:
                                          - type: string
                                            title: string
                                            description: String
                                          - type: number
                                            title: number
                                            description: Number
                                          - type: boolean
                                            title: boolean
                                            description: Boolean
                                  required:
                                    - nin
                                  title: nin
                                  description: Not in
                                - type: object
                                  properties:
                                    exists:
                                      type: boolean
                                  required:
                                    - exists
                                  title: exists
                                  description: Exists
                      required:
                        - and
                      title: and
                      description: And
                    - type: object
                      properties:
                        or:
                          type: array
                          items:
                            type: object
                            additionalProperties:
                              anyOf:
                                - type: object
                                  properties:
                                    eq:
                                      anyOf:
                                        - type: string
                                          title: string
                                          description: String
                                        - type: number
                                          title: number
                                          description: Number
                                        - type: boolean
                                          title: boolean
                                          description: Boolean
                                  required:
                                    - eq
                                  title: eq
                                  description: Equal to
                                - type: object
                                  properties:
                                    ne:
                                      anyOf:
                                        - type: string
                                          title: string
                                          description: String
                                        - type: number
                                          title: number
                                          description: Number
                                        - type: boolean
                                          title: boolean
                                          description: Boolean
                                  required:
                                    - ne
                                  title: ne
                                  description: Not equal to
                                - type: object
                                  properties:
                                    gt:
                                      type: number
                                  required:
                                    - gt
                                  title: gt
                                  description: Greater than
                                - type: object
                                  properties:
                                    gte:
                                      type: number
                                  required:
                                    - gte
                                  title: gte
                                  description: Greater than or equal to
                                - type: object
                                  properties:
                                    lt:
                                      type: number
                                  required:
                                    - lt
                                  title: lt
                                  description: Less than
                                - type: object
                                  properties:
                                    lte:
                                      type: number
                                  required:
                                    - lte
                                  title: lte
                                  description: Less than or equal to
                                - type: object
                                  properties:
                                    in:
                                      type: array
                                      items:
                                        anyOf:
                                          - type: string
                                            title: string
                                            description: String
                                          - type: number
                                            title: number
                                            description: Number
                                          - type: boolean
                                            title: boolean
                                            description: Boolean
                                  required:
                                    - in
                                  title: in
                                  description: In
                                - type: object
                                  properties:
                                    nin:
                                      type: array
                                      items:
                                        anyOf:
                                          - type: string
                                            title: string
                                            description: String
                                          - type: number
                                            title: number
                                            description: Number
                                          - type: boolean
                                            title: boolean
                                            description: Boolean
                                  required:
                                    - nin
                                  title: nin
                                  description: Not in
                                - type: object
                                  properties:
                                    exists:
                                      type: boolean
                                  required:
                                    - exists
                                  title: exists
                                  description: Exists
                      required:
                        - or
                      title: or
                      description: Or
                  description: >-
                    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.
                search_options:
                  type: object
                  properties:
                    include_vectors:
                      type: boolean
                      description: Whether to include the vector in the chunk
                    include_metadata:
                      type: boolean
                      description: Whether to include the metadata in the chunk
                    include_scores:
                      type: boolean
                      description: Whether to include the scores in the chunk
                  description: Additional search options
                rerank_config:
                  type: object
                  properties:
                    model:
                      type: string
                      description: >-
                        The name of the rerank model to use. Refer to the [model
                        list](https://docs.orq.ai/docs/proxy#/rerank-models).
                      example: cohere/rerank-multilingual-v3.0
                    threshold:
                      type: number
                      minimum: 0
                      maximum: 1
                      default: 0
                      description: >-
                        The threshold value used to filter the rerank results,
                        only documents with a relevance score greater than the
                        threshold will be returned
                    top_k:
                      type: integer
                      minimum: 1
                      maximum: 100
                      default: 10
                      description: >-
                        The number of top results to return after reranking. If
                        not provided, will default to the knowledge base
                        configured `top_k`.
                  required:
                    - model
                  description: >-
                    Override the rerank configuration for this search. If not
                    provided, will use the knowledge base configured rerank
                    settings.
                agentic_rag_config:
                  type: object
                  properties:
                    model:
                      type: string
                      description: >-
                        The name of the model for the Agent to use. Refer to the
                        [model
                        list](https://docs.orq.ai/docs/proxy#/chat-models).
                  required:
                    - model
                  description: >-
                    Override the agentic RAG configuration for this search. If
                    not provided, will use the knowledge base configured agentic
                    RAG settings.
              required:
                - query
      responses:
        '200':
          description: Search knowledge base
          content:
            application/json:
              schema:
                type: object
                properties:
                  matches:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        text:
                          type: string
                        vector:
                          type: array
                          items:
                            type: number
                        metadata:
                          type: object
                          additionalProperties: {}
                        scores:
                          type: object
                          properties:
                            rerank_score:
                              type: number
                            search_score:
                              type: number
                      required:
                        - id
                        - text
                required:
                  - matches
components:
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer
      bearerFormat: JWT

````