Skip to main content
POST
/
retrieve
/
chunks
/
grouped
JavaScript
import Morphik from 'morphik';

const client = new Morphik({
  apiKey: 'My API Key',
});

const response = await client.retrieve.chunks.createGrouped({ query: 'x' });

console.log(response.chunks);
{
  "chunks": [
    {
      "content": "<string>",
      "score": 123,
      "document_id": "<string>",
      "chunk_number": 123,
      "metadata": {},
      "content_type": "<string>",
      "filename": "<string>",
      "download_url": "<string>",
      "is_padding": true
    }
  ],
  "groups": [
    {
      "main_chunk": {
        "content": "<string>",
        "score": 123,
        "document_id": "<string>",
        "chunk_number": 123,
        "metadata": {},
        "content_type": "<string>",
        "filename": "<string>",
        "download_url": "<string>",
        "is_padding": true
      },
      "padding_chunks": [
        {
          "content": "<string>",
          "score": 123,
          "document_id": "<string>",
          "chunk_number": 123,
          "metadata": {},
          "content_type": "<string>",
          "filename": "<string>",
          "download_url": "<string>",
          "is_padding": true
        }
      ],
      "total_chunks": 123
    }
  ],
  "total_results": 123,
  "has_padding": true
}

Headers

authorization
string

Body

application/json

Base retrieve request model

query
string
required
Minimum length: 1
filters
object | null
k
integer
default:4
Required range: x > 0
min_score
number
default:0
use_reranking
boolean | null
use_colpali
boolean | null
padding
integer
default:0

Number of additional chunks/pages to retrieve before and after matched chunks (ColPali only)

Required range: x >= 0
graph_name
string | null

Name of the graph to use for knowledge graph-enhanced retrieval

hop_depth
integer | null
default:1

Number of relationship hops to traverse in the graph

Required range: 1 <= x <= 3
include_paths
boolean | null
default:false

Whether to include relationship paths in the response

folder_name

Optional folder scope for the operation. Accepts a single folder name or a list of folder names.

end_user_id
string | null

Optional end-user scope for the operation

Response

Successful Response

Response that includes both flat results and grouped results for UI

chunks
ChunkResult · object[]
required

Flat list of all chunks (for backward compatibility)

groups
ChunkGroup · object[]
required

Grouped chunks for UI display

total_results
integer
required

Total number of unique chunks

has_padding
boolean
required

Whether padding was applied to any results

I