Grouping and ungrouping search results
Grouping and ungrouping refer to the process of organizing the results of a search request in a specific way. The platform allows for grouping based on the unique identifiers of the videos. For example, this is useful when building a user interface, because it allows your users to better understand and navigate the search results. On the other hand, ungrouping presents your search results in a flat list. This is useful if you want to view all of the search results in a simple manner. Note that this feature can only be used with simple queries.
To group or ungroup items in a response, use the group_by
parameter, specifying one of the following values:
video
: The platform will group the matching video clips in the response by video.clip
: The matching video clips in the response will not be grouped.
Note
The group_by
parameter is optional and its default value is clip
. If omitted, the platform will use the default value. For clarity, the examples in this section always specify the group_by
parameter.
For a description of each field in the request and response, see the API Reference> Make any-to-video search requests page.
Prerequisites
- You’re familiar with the concepts that are described on the Platform overview page.
- You’ve already created an index, and the Marengo video understanding engine is enabled for this index.
- You’ve already uploaded a video, and the platform has finished indexing it.
Examples
Grouping items in a response
The following example code groups the matching video clips in the response by video:
The output should look similar to the following one:
In this example, note that the data
array contains a list of objects. Each object corresponds to a video that matches your query and is composed of the following key-value pairs:
clips
: An array that groups the information about all the matching video clips in that video.id
: The unique identifier of the video that matched your query.
Ungrouping items in a response
The following example performs a search request, and the matching video clips in the response are not grouped:
The output should look similar to the following one: