## Retrieve

`$ llamacloud-prod beta:retrieval retrieve`

**post** `/api/v1/retrieval/retrieve`

Retrieve relevant chunks via hybrid search (vector + full-text), with filtering on built-in or user-defined metadata.

### Parameters

- `--index-id: string`

  Body param: ID of the index to retrieve against.

- `--query: string`

  Body param: Natural-language query to retrieve relevant chunks.

- `--organization-id: optional string`

  Query param

- `--project-id: optional string`

  Query param

- `--custom-filters: optional map[object { operator, value }  or array of object { operator, value } ]`

  Body param: Filters on user-defined metadata fields.

- `--full-text-pipeline-weight: optional number`

  Body param: Weight of the full-text search pipeline (0-1).

- `--num-candidates: optional number`

  Body param: Number of candidates for approximate nearest neighbor search.

- `--rerank: optional object { enabled, top_n }`

  Body param: Reranking configuration applied after hybrid search. Enabled by default.

- `--score-threshold: optional number`

  Body param: Minimum score threshold for returned results.

- `--static-filters: optional object { parsed_directory_file_id }`

  Body param: Filters on built-in document fields (page range, chunk index, etc.).

- `--top-k: optional number`

  Body param: Maximum number of results to return.

- `--vector-pipeline-weight: optional number`

  Body param: Weight of the vector search pipeline (0-1).

### Returns

- `BetaRetrievalGetResponse: object { results }`

  Response containing retrieval results.

  - `results: array of object { content, metadata, rerank_score, 2 more }`

    Ordered list of retrieved chunks.

    - `content: string`

      Text content of the retrieved chunk.

    - `metadata: optional map[string or number or boolean or array of string]`

      User-defined metadata associated with the chunk.

      - `union_member_0: string`

      - `union_member_1: number`

      - `union_member_2: boolean`

      - `union_member_3: array of string`

    - `rerank_score: optional number`

      Relevance score from the reranker, if reranking was applied.

    - `score: optional number`

      Hybrid search relevance score.

    - `static_fields: optional object { attachments, chunk_end_char, chunk_index, 5 more }`

      Built-in fields stored for every exported chunk.

      - `attachments: optional array of object { attachment_name, source_id, type }`

        Attachments associated with the chunk

        - `attachment_name: string`

          Attachment-relative path, e.g. 'screenshots/page_7.jpg'.

        - `source_id: string`

          File ID to pass as source_id when fetching the attachment.

        - `type: string`

          Attachment kind, e.g. 'screenshot', 'items'.

      - `chunk_end_char: optional number`

        End character offset of the chunk.

      - `chunk_index: optional number`

        Index of the chunk within the file.

      - `chunk_start_char: optional number`

        Start character offset of the chunk.

      - `chunk_token_count: optional number`

        Token count of the chunk.

      - `page_range_end: optional number`

        Last page number covered by this chunk.

      - `page_range_start: optional number`

        First page number covered by this chunk.

      - `parsed_directory_file_id: optional string`

        ID of the parsed file.

### Example

```cli
llamacloud-prod beta:retrieval retrieve \
  --api-key 'My API Key' \
  --index-id idx-abc123 \
  --query 'What are the key findings?'
```

#### Response

```json
{
  "results": [
    {
      "content": "content",
      "metadata": {
        "foo": "string"
      },
      "rerank_score": 0,
      "score": 0,
      "static_fields": {
        "attachments": [
          {
            "attachment_name": "attachment_name",
            "source_id": "source_id",
            "type": "type"
          }
        ],
        "chunk_end_char": 0,
        "chunk_index": 0,
        "chunk_start_char": 0,
        "chunk_token_count": 0,
        "page_range_end": 0,
        "page_range_start": 0,
        "parsed_directory_file_id": "parsed_directory_file_id"
      }
    }
  ]
}
```
