For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sample appsIntegrationsDiscordPlaygroundDevEx repo
GuidesSDK ReferenceAPI Reference
GuidesSDK ReferenceAPI Reference
  • Get Started
    • Introduction
    • Quickstart
    • Manage your plan
    • Rate limits
    • Release notes
    • Migration guide
  • Guides
    • Search
      • Search with text, image, and composed queries
      • Entity search
      • Query engineering
      • Grouping
      • Filtering
    • Analyze videos
    • Segment videos
    • Create embeddings
  • Concepts
    • Models
    • Upload and processing methods
    • Indexes
    • Modalities
    • Multimodal large language models
  • Cloud partner integrations
    • Amazon Bedrock
  • Advanced
    • Organizations
    • Fine-tuning
    • Webhooks
    • Metadata
    • Model context protocol
    • Claude Code Plugin
  • Resources
    • Platform overview
    • Playground
    • TwelveLabs SDKs
    • Frequently asked questions
    • Use cases
    • Sample applications
    • Partner integrations
    • From the community
LogoLogo
Sample appsIntegrationsDiscordPlaygroundDevEx repo
GuidesSearch

Grouping

Was this page helpful?
Previous

Filtering

Next
Built with

Grouping and ungrouping allow you to organize search results in different ways. The platform organizes matching clips under their respective videos when you group them by video. This helps when building a user interface, because it allows your users to better understand and navigate the search results. When you ungroup, the platform presents all matching clips in a flat list, which is useful for a simple view of all results.

Python
Node.js

When you set group_by to video, the response contains an array of objects, each object corresponding to a video that matches your query and includes the following fields:

  • id: The unique identifier of the video.
  • clips: An array that groups the information about all the matching video clips in that video.
Python
1search_pager = client.search.query(
2 index_id="<YOUR_INDEX_ID>",
3 query_text="<YOUR_QUERY>",
4 search_options=["visual"],
5 group_by="video",
6)
7for group in search_pager:
8 if group.clips is None:
9 continue
10 print(f" Video ID: {group.id}")
11 for clip in group.clips:
12 print(
13 f" rank={clip.rank} start={clip.start} end={clip.end}"
14 )