Text queries
Text queries allow you to use natural language to find video segments matching specific keywords or phrases.
Note the following about using text queries:
- The platform supports full natural language-based search. The following examples are valid queries: “birds flying near a castle,” “sun shining on the water,” “chickens on the road,” “an officer holding a child’s hand,” and “crowd cheering in the stadium.”
- The platform supports queries in multiple languages. For a complete list, see the Supported languages page.
Examples
This section provides examples of performing search requests using single queries. Ensure that the prerequisites are met before proceeding.
Visual
The platform analyzes video content as you would see and hear from it, including actions, objects, sounds, and events, excluding human speech. To search using visual cues, invoke the query
method of the search
object with the following parameters:
index_id
: A string representing the unique identifier of the index to search.query_text
: A string representing your search query. Note that the platform supports full natural language-based search. The following examples are valid queries: “birds flying near a castle,” “sun shining on the water,” “chickens on the road,” “an officer holding a child’s hand,” and “crowd cheering in the stadium.”options
: An array of strings specifying the sources of information the platform uses when performing a search. This example searches using visual cues.
The example output below was truncated for brevity:
Conversation
The platform analyzes human speech within your videos. The following example sets the value of the options
parameter to ["conversation"]
to search using human speech as the source of information. Note that you can perform semantic and exact searches by setting the value of the conversation_option
parameter. See the Conversation option page for details.
The example output below was truncated for brevity:
Text in video
The platform detects and extracts text (OCR) shown within your videos. The following example sets the value of the options
parameter to ["text_in_video"]
to search for text that matches your search query:
Logo
The platform detects and extracts brand logos as shown within your videos. For this, call the query
method of the search
object with the following parameters:
query_text
: The name of the company. This example uses Starbucks.options
: The source of information the platform must use (logo
).index_id
: The unique identifier of the index containing your videos.
The example code below finds when the Starbucks company logo appears in your videos:
The following example output was truncated for brevity:
In this example output, the Starbucks logo appears at 104 seconds from the start of the video:
Visual and conversation
The following example sets the value options
parameter to ["visual", "conversation"]
and the value of the operator
parameter to or
to specify that the platform should return the results for which any of the selected sources of information match:
The example output below was truncated for brevity:
The following example sets the value options
parameter to ["visual", "conversation"]
and the value of the operator
parameter to and
to specify that the platform should return the results for which all the selected sources of information match:
The example output below was truncated for brevity:
Conversation and text in video
The following example sets the value options
parameter to ["conversation", "text_in_video"]
and the value of the operator
parameter to or
to specify that the platform should return the results for which any of the selected sources of information match:
The example output below was truncated for brevity:
The following example sets the value options
parameter to ["conversation", "text_in_video"]
and the value of the operator
parameter to and
to specify that the platform should return only the results for which all the selected sources of information match:
The example output below was truncated for brevity:
Conversation, text in video, and visual
The following example sets the value options
parameter to ["conversation", "text_in_video", "visual"]
and the value of the operator
parameter to or
to specify that the platform should return the results for which any of the selected sources of information match:
The example output below was truncated for brevity:
The following example sets the value options
parameter to ["conversation", "text_in_video", "visual"]
and the value of the operator
parameter to and
to specify that the platform should return the results for which all the selected sources of information match:
The example output below was truncated for brevity: