Skip to main content
The following information applies to the legacy Unstructured Partition Endpoint.Unstructured recommends that you use the local-file processing jobs functionality in the Unstructured Pipeline API instead. Unstructured’s local-file processing jobs provide many benefits over the legacy Unstructured Partition Endpoint, including support for:
  • Production-level usage.
  • Multiple local input files in batches.
  • The latest and highest-performing models.
  • Post-transform enrichments.
  • All of Unstructured’s chunking strategies.
  • The generation of vector embeddings.
The Unstructured API also provides support for processing files and data in remote locations.

Task

You want to get, and print or save, the contents of elements that have been chunked.

Approach

Chunked elements are typically represented in this format:
To get the element’s chunked content, extract the contents of the element’s text field. The chunked content might not contain all of its associated content. To get all of the elements that were used to derive this chunked content, extract the contents of the element’s orig_elements field, which is nested inside of its parent metadata field. The contents of the orig_elements field is in compressed Base64 gzipped format. To get the content, Base64-decode the bytes, decompress them, and then decode them using UTF-8.

To run this example

You will need to chunk a document during processing. This example uses a PDF file chunked into 200- to 300-character elements.

Code

For the Unstructured Python SDK, you’ll need: These environment variables:
  • UNSTRUCTURED_API_KEY - Your Unstructured API key value.
  • UNSTRUCTURED_API_URL - Your Unstructured API URL.

See also