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

# Search

> Search for nodes in the graph database.

This endpoint performs semantic search across the knowledge graph to find
relevant nodes based on the provided query. It supports different search
types and can be scoped to specific datasets.

## Request Parameters
- **search_type** (SearchType): Type of search to perform
- **datasets** (Optional[List[str]]): List of dataset names to search within
- **dataset_ids** (Optional[List[UUID]]): List of dataset UUIDs to search within
- **query** (str): The search query string
- **system_prompt** Optional[str]: System prompt to be used for Completion type searches in Cognee
- **node_name** Optional[list[str]]: Filter results to specific node_sets defined in the add pipeline (for targeted search).
- **top_k** (Optional[int]): Maximum number of results to return (default: 10)
- **only_context** bool: Set to true to only return context Cognee will be sending to LLM in Completion type searches. This will be returned instead of LLM calls for completion type searches.

## Response
Returns a list of search results containing relevant nodes from the graph.

## Error Codes
- **409 Conflict**: Error during search operation
- **403 Forbidden**: User doesn't have permission to search datasets (returns empty list)

## Notes
- Datasets sent by name will only map to datasets owned by the request sender
- To search datasets not owned by the request sender, dataset UUID is needed
- If permission is denied, returns empty list instead of error



## OpenAPI

````yaml /cognee_openapi_spec.json post /api/v1/search
openapi: 3.1.0
info:
  title: Cognee API
  description: Cognee API with Bearer token and Cookie auth
  version: 1.0.0
servers:
  - url: https://api.cognee.ai
    description: Production server (full functionality)
  - url: http://localhost:8000
    description: Local development server (requires local setup)
security:
  - BearerAuth: []
  - ApiKeyAuth: []
tags:
  - name: activity
    description: ''
  - name: add
    description: Data ingestion endpoints for adding text, files, and structured data.
  - name: auth
    description: >-
      Authentication endpoints for user registration, login, and token
      management.
  - name: checks
    description: ''
  - name: cognify
    description: >-
      Knowledge processing endpoints to transform raw data into knowledge
      graphs.
  - name: configuration
    description: ''
  - name: datasets
    description: Dataset management endpoints for listing, creating, and deleting datasets.
  - name: delete
    description: Data deletion endpoints (deprecated — use datasets endpoints instead).
  - name: forget
    description: ''
  - name: health
    description: ''
  - name: improve
    description: ''
  - name: llm
    description: ''
  - name: memify
    description: ''
  - name: notebooks
    description: ''
  - name: ontologies
    description: ''
  - name: permissions
    description: Permission management for multi-user access control.
  - name: recall
    description: ''
  - name: remember
    description: ''
  - name: responses
    description: Response generation endpoints using the knowledge graph.
  - name: search
    description: Search endpoints for querying the knowledge graph.
  - name: sessions
    description: ''
  - name: settings
    description: Configuration endpoints for managing Cognee settings.
  - name: sync
    description: ''
  - name: update
    description: ''
  - name: users
    description: User management endpoints.
  - name: visualize
    description: Graph visualization endpoints.
paths:
  /api/v1/search:
    post:
      tags:
        - search
      summary: Search
      description: >-
        Search for nodes in the graph database.


        This endpoint performs semantic search across the knowledge graph to
        find

        relevant nodes based on the provided query. It supports different search

        types and can be scoped to specific datasets.


        ## Request Parameters

        - **search_type** (SearchType): Type of search to perform

        - **datasets** (Optional[List[str]]): List of dataset names to search
        within

        - **dataset_ids** (Optional[List[UUID]]): List of dataset UUIDs to
        search within

        - **query** (str): The search query string

        - **system_prompt** Optional[str]: System prompt to be used for
        Completion type searches in Cognee

        - **node_name** Optional[list[str]]: Filter results to specific
        node_sets defined in the add pipeline (for targeted search).

        - **top_k** (Optional[int]): Maximum number of results to return
        (default: 10)

        - **only_context** bool: Set to true to only return context Cognee will
        be sending to LLM in Completion type searches. This will be returned
        instead of LLM calls for completion type searches.


        ## Response

        Returns a list of search results containing relevant nodes from the
        graph.


        ## Error Codes

        - **409 Conflict**: Error during search operation

        - **403 Forbidden**: User doesn't have permission to search datasets
        (returns empty list)


        ## Notes

        - Datasets sent by name will only map to datasets owned by the request
        sender

        - To search datasets not owned by the request sender, dataset UUID is
        needed

        - If permission is denied, returns empty list instead of error
      operationId: search_api_v1_search_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SearchPayloadDTO'
            example:
              search_type: GRAPH_COMPLETION
              query: What is Cognee?
              top_k: 10
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                anyOf:
                  - items:
                      $ref: '#/components/schemas/SearchResult'
                    type: array
                  - items: {}
                    type: array
                title: Response Search Api V1 Search Post
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Forbidden
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal Server Error
      security:
        - BearerAuth: []
        - ApiKeyAuth: []
components:
  schemas:
    SearchPayloadDTO:
      properties:
        searchType:
          $ref: '#/components/schemas/SearchType'
          default: GRAPH_COMPLETION
        datasets:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Datasets
        datasetIds:
          anyOf:
            - items:
                type: string
                format: uuid
              type: array
            - type: 'null'
          title: Datasetids
          examples:
            - []
        query:
          type: string
          title: Query
          default: What is in the document?
        systemPrompt:
          anyOf:
            - type: string
            - type: 'null'
          title: Systemprompt
          default: >-
            Answer the question using the provided context. Be as brief as
            possible.
        nodeName:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Nodename
          example: []
        topK:
          anyOf:
            - type: integer
            - type: 'null'
          title: Topk
          default: 10
        onlyContext:
          type: boolean
          title: Onlycontext
          default: false
        verbose:
          type: boolean
          title: Verbose
          default: false
      type: object
      title: SearchPayloadDTO
    SearchResult:
      properties:
        search_result:
          title: Search Result
        dataset_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Dataset Id
        dataset_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Dataset Name
      type: object
      required:
        - search_result
        - dataset_id
        - dataset_name
      title: SearchResult
    ErrorResponse:
      properties:
        error:
          type: string
          title: Error
        detail:
          anyOf:
            - type: string
            - type: 'null'
          title: Detail
      type: object
      required:
        - error
      title: ErrorResponse
    SearchType:
      type: string
      enum:
        - SUMMARIES
        - CHUNKS
        - RAG_COMPLETION
        - TRIPLET_COMPLETION
        - GRAPH_COMPLETION
        - GRAPH_COMPLETION_DECOMPOSITION
        - GRAPH_SUMMARY_COMPLETION
        - CYPHER
        - NATURAL_LANGUAGE
        - GRAPH_COMPLETION_COT
        - GRAPH_COMPLETION_CONTEXT_EXTENSION
        - FEELING_LUCKY
        - TEMPORAL
        - CODING_RULES
        - CHUNKS_LEXICAL
      title: SearchType
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key

````