Use simple queries
This section shows how to perform searches using simple queries. For a description of each field in the request and response, see the API Reference > Make a search request page.
Prerequisites
The examples in this guide assume the following:
- You’re familiar with the concepts that are described on the Platform overview page.
- You’ve uploaded at least one video to your index, and the platform has finished indexing it. For details, see the Upload videos page.
Using a single source of information
Note that, when you perform a search using a single source of information, for each matching video segment, the platform returns, among other information, a field named metadata
. It is an array of objects where each object contains details about the source of information that matched your search terms and is composed of the following key-value pairs:
type
: Represents the source of information for which the video segment matched your search terms. It can take one of the following values:visual
,conversation
,text_in_video
, andlogo
.- (Optional)
text
: Forconversation
andtext_in_video
, the platform returns a field namedtext
, representing the text that matches your search terms. When performing a semantic search, the platform determines the meaning of your search query, rather than just matching your search terms to the content of your videos. This means that the value of this field doesn't always match your search terms.
Example:
"metadata": [
{
"type": "conversation",
"text": "The safety car has gone, the lights gone green and there's a big crash at the back and that is the Alfa Romeo, certainly Antonio was involved in that skirmish as well."
}
]
Visual
The platform allows you to analyze video content as you would see and hear from it, including actions, objects, sounds, and events, excluding human speech. The following example sets the value of the search_options
parameter to ["visual"]
to search for car accidents using visual cues:
SEARCH_URL = f"{API_URL}/search"
data = {
"query": "car accidents",
"index_id": INDEX_ID,
"search_options": ["visual"],
}
response = requests.post(SEARCH_URL, headers={"x-api-key": API_KEY}, json=data)
print (f"Status code: {response.status_code}")
pprint (response.json())
const SEARCH_URL = `${API_URL}/search`
const data = JSON.stringify(
{
'query': 'car accidents',
'index_id': INDEX_ID,
'search_options': ['visual'],
})
const config = {
method: 'post',
url: SEARCH_URL,
headers: headers,
data: data
}
const resp = await axios(config)
const response = await resp.data
console.log(`Status code: ${resp.status}`)
console.log(response)
The example output below was truncated for brevity:
Status code: 200
{'data': [{'confidence': 'high',
'end': 492,
'metadata': [{'type': 'visual'}],
'score': 91.02,
'start': 486,
'video_id': '626a3de4ba9f116e5ea92a38'},
{'confidence': 'medium',
'end': 216,
'metadata': [{'type': 'visual'}],
'score': 75.88,
'start': 210,
'video_id': '626a3de4ba9f116e5ea92a38'},
'page_info': {'limit_per_page': 10,
'next_page_token': '8fda6c80-3132-4f3c-8d57-cd314823d429-1',
'page_expired_at': '2022-04-28T07:28:38Z',
'total_results': 14},
'query': 'car accident',
'search_options': ['visual'],
'search_pool': {'index_id': '626a273122c7851fcbe5c842',
'total_count': 2,
'total_duration': 582},
'type': 'search_create'}
Conversation
The platform allows you to analyze human speech within your videos.
Note that you can perform both semantic and exact searches. For details, see the Conversation option page.
The following example sets the value of the search_options
parameter to ["conversation"]
to perform a semantic search and returns the matches for the specified search term - "car accidents":
SEARCH_URL = f"{API_URL}/search"
data = {
"query": "car accidents",
"index_id": INDEX_ID,
"search_options": ["conversation"],
"conversation_option": "semantic",
}
response = requests.post(SEARCH_URL, headers=headers, json=data)
print (f"Status code: {response.status_code}")
pprint (response.json())
const SEARCH_URL = `${API_URL}/search`
const data = JSON.stringify(
{
'query': 'car accidents',
'index_id': INDEX_ID,
'search_options': ['conversation'],
'conversation_option': 'semantic',
})
const config = {
method: 'post',
url: SEARCH_URL,
headers: headers,
data: data
}
const resp = await axios(config)
const response = await resp.data
console.log(`Status code: ${resp.status}`)
console.log(response)
The example output below was truncated for brevity:
Status code: 200
{'conversation_option': 'semantic',
'data': [{'confidence': '',
'end': 386.06,
'metadata': [{'text': "Let's show the class and that is a very big "
'accident. A huge accident at the parabolic '
'to Are you okay?',
'type': 'conversation'}],
'score': 86.05,
'start': 377.54,
'video_id': '626a3de4ba9f116e5ea92a38'},
{'confidence': '',
'end': 38.85,
'metadata': [{'text': "That's a big impact Both ends of the car "
"felt that one. I don't know if it was a "
'puncture or a suspension failure.',
'type': 'conversation'}],
'score': 83.87,
'start': 31.23,
'video_id': '626a3de4ba9f116e5ea92a38'},
{'confidence': '',
'end': 413.28,
'metadata': [{'text': "Okay. He's lost the back end of the car "
'under acceleration. The back end got away '
'from him and he counter stared into the '
'slide. I just loved the car.',
'type': 'conversation'}],
'score': 72.92,
'start': 403.34,
'video_id': '626a3de4ba9f116e5ea92a38'}],
'page_info': {'limit_per_page': 10,
'next_page_token': 'c08e69fa-790e-46f7-bbd6-f391d625c20d-1',
'page_expired_at': '2022-05-02T05:48:06Z',
'total_results': 24},
'query': 'car accident',
'search_options': ['conversation'],
'search_pool': {'index_id': '626a273122c7851fcbe5c842',
'total_count': 21,
'total_duration': 1153},
'type': 'search_create'}
Text in video
The platform allows you to detect and extract text (OCR) shown within your videos. The following example sets the value of the search_options
parameter to ["text_in_video"]
to search for text that matches "bear cubs":
SEARCH_URL = f"{API_URL}/search"
data = {
"query": "bear cubs",
"index_id": INDEX_ID,
"search_options": ["text_in_video"],
}
response = requests.post(SEARCH_URL, headers=headers, json=data)
print (f"Status code: {response.status_code}")
pprint (response.json())
const SEARCH_URL = `${API_URL}/search`
const data = JSON.stringify(
{
'query': 'bear cubs',
'index_id': INDEX_ID,
'search_options': ['text_in_video'],
})
const config = {
method: 'post',
url: SEARCH_URL,
headers: headers,
data: data
}
const resp = await axios(config)
const response = await resp.data
console.log(`Status code: ${resp.status}`)
console.log(response)
The example output below was truncated for brevity:
Status code: 200
{'data': [{'confidence': 'high',
'end': 238,
'metadata': [{'text': 'bear cubs', 'type': 'text_in_video'}],
'score': 92.28,
'start': 233,
'video_id': '626a3de4ba9f116e5ea92a38'}],
'page_info': {'limit_per_page': 10,
'page_expired_at': '2022-04-29T06:03:34Z',
'total_results': 1},
'query': 'Alex Albon',
'search_options': ['text_in_video'],
'search_pool': {'index_id': '626a273122c7851fcbe5c842',
'total_count': 3,
'total_duration': 612},
'type': 'search_create'}
Logo
The platform allows you to detect and extract brand logos as shown within your videos. For this, call the POST
method of the /search
endpoint with the following parameters:
query
: The name of the companysearch_options
: The source of information the platform uses (logo
)index_id
: The unique identifier of the index you've previously created
The example code below finds when the Starbucks company logo appears in your videos:
SEARCH_URL = f"{API_URL}/search"
data = {
"query": "Starbucks",
"index_id": INDEX_ID,
"search_options": ["logo"]
}
response = requests.post(SEARCH_URL, headers=headers, json=data)
print(f"Status code: {response.status_code}")
pprint(response.json())
const SEARCH_URL = `${API_URL}/search`
const data = {
'query': 'Starbucks',
'index_id': INDEX_ID,
'search_options': ['logo']
}
const resp = await axios.post(
SEARCH_URL,
data,
{
'headers': {
'x-api-key': API_KEY
}
}
)
const { data: response } = resp;
console.log(`Status code: ${resp.status}`)
console.log(JSON.stringify(response,null,4))
The following example output was truncated for brevity:
Status code: 200
{
"search_pool": {
"total_count": 4,
"total_duration": 1634,
"index_id": "63eb49211b8502baddec7391"
},
"data": [
{
"score": 92.28,
"start": 104,
"end": 106,
"metadata": [
{
"type": "logo",
"text": "Starbucks"
}
],
"video_id": "63eb67e49678ed7709731d63",
"confidence": "high"
}
],
"page_info": {
"limit_per_page": 10,
"total_results": 5,
"page_expired_at": "2023-02-17T06:18:47Z"
}
}
In this example output, the Starbucks logo appears at 104 seconds from the start of the video:
Using multiple sources of information
When you perform a search specifying multiple sources of information, you can use the operator
parameter to broaden or narrow your search. The following logical operators are supported:
OR
: The platform returns the results for which any search option matches.AND
: The platform returns only the results for which all search options match.
The diagram below explains the difference between specifying the OR
and AND
logical operators:
Note that, for each matching video segment, the platform returns, among other information, the following fields:
-
modules
: An array where each element is a dictionary composed of the following key-value pairs:type
: The source of information for which the video segment matched your search terms. It can take one of the following values:conversation
,visual
,text_in_video
, andlogo
.confidence
: The confidence level that the result is accurate
The following example shows that a video segment matched your search terms using two sources of information -
visual
andconversation
:"modules": [ { "type": "conversation", "confidence": "medium" }, { "type": "visual", "confidence": "low" } ]
-
metadata
: An array of objects where each object contains details about the source of information that matched your search terms and is composed of the following key-value pairs:type
: Represents the source of information for which the video segment matched your search terms. It can take one of the following values:visual
,conversation
,text_in_video
, andlogo
.- (Optional)
text
: Forconversation
andtext_in_video
, the platform returns a field namedtext
, representing the text that matches your search terms. When performing a semantic search, the platform determines the meaning of your search query, rather than just matching your search terms to the content of your videos. This means that the value of this field doesn't always match your search terms.
The following example shows that two sources of information matched your search terms -
conversation
andvisual
:"metadata": [ { "type": "conversation", "text": "The safety car has gone, the lights gone green and there's a big crash at the back and that is the Alfa Romeo, certainly Antonio was involved in that skirmish as well." }, { "type": "visual" } ]
For a description of each field in the response, see the API Reference > Make a Search Request page.
Notes
- The
operator
parameter is optional. If omitted, the platform will perform a logicalOR
operation. For clarity, the examples in this section always specify theoperator
parameter.
Visual and conversation
The following example combines visual
and conversation
, using the logical OR
operator to specify that the API should return the results for which any source of information matches:
SEARCH_URL = f"{API_URL}/search"
data = {
"query": "car accidents",
"index_id": INDEX_ID,
"search_options": ["visual", "conversation"],
"operator": "or"
}
response = requests.post(SEARCH_URL, headers=headers, json=data)
print (f"Status code: {response.status_code}")
pprint (response.json())
const SEARCH_URL = `${API_URL}/search`
const data = JSON.stringify(
{
'query': 'car accidents',
'index_id': INDEX_ID,
'search_options': ['visual', 'conversation'],
'operator': 'or'
})
const config = {
method: 'post',
url: SEARCH_URL,
headers: headers,
data: data
}
const resp = await axios(config)
const response = await resp.data
console.log(`Status code: ${resp.status}`)
console.log(response)
The example output below was truncated for brevity:
Status code: 200
{
"search_pool": {
"total_count": 13,
"total_duration": 8731,
"index_id": "639961c9e219c90227c371a2"
},
"data": [
{
"score": 76.79,
"start": 420.66,
"end": 430.23,
"metadata": [
{
"type": "conversation",
"text": "The safety car has gone, the lights gone green and there's a big crash at the back and that is the Alfa Romeo, certainly Antonio, joven Nazi was involved in that skirmish as well."
},
{
"type": "visual"
}
],
"video_id": "639963a1ce36463e0199c8c7",
"confidence": "medium",
"thumbnail_url": "https://project-one-thumbnail.s3.us-west-2.amazonaws.com/639963a1ce36463e0199c8c7/421.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYRWJPOVHXE5SJ77T%2F20221222%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221222T171200Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=73b9c5bdd99049a3ee08c6e33bd745f28e70657be9c42ec797e04087703302f0",
"modules": [
{
"type": "conversation",
"confidence": "medium"
},
{
"type": "visual",
"confidence": "low"
}
]
},
{
"score": 72.27,
"start": 279.21875,
"end": 289.75,
"metadata": [
{
"type": "visual"
}
],
"video_id": "639963a1ce36463e0199c8c7",
"confidence": "low",
"thumbnail_url": "https://project-one-thumbnail.s3.us-west-2.amazonaws.com/639963a1ce36463e0199c8c7/280.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYRWJPOVHXE5SJ77T%2F20221222%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221222T171200Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=cbecee456af2403d2cacbeef60c65abf4f0af12a16969c80ef2914131737c435",
"modules": [
{
"type": "visual",
"confidence": "low"
}
]
},
{
"score": 72.2,
"start": 87.38,
"end": 98.73,
"metadata": [
{
"type": "conversation",
"text": "thought I had it, but then obviously you get the results so we'll have a look at the data. We've had an accident."
}
],
"video_id": "639963a1ce36463e0199c8c7",
"confidence": "low",
"thumbnail_url": "https://project-one-thumbnail.s3.us-west-2.amazonaws.com/639963a1ce36463e0199c8c7/88.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYRWJPOVHXE5SJ77T%2F20221222%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221222T171159Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=7c658b451ab6004f20837cd88f35dcf8cdd732a83a8d11f74ff2ca2b64681079",
"modules": [
{
"type": "conversation",
"confidence": "low"
}
]
}
],
"page_info": {
"limit_per_page": 10,
"total_results": 226,
"page_expired_at": "2022-12-22T17:12:00Z",
"next_page_token": "d9303b41-7bd8-4149-b071-7815f2d17c85-1"
}
}
The following example combines the visual
and conversation
search options, using the logical AND
operator to specify that the API should return only the results for which all search options match:
SEARCH_URL = f"{API_URL}/search"
data = {
"query": "car accidents",
"index_id": INDEX_ID,
"search_options": ["visual", "conversation"],
"operator": "and"
}
response = requests.post(SEARCH_URL, headers=headers, json=data)
print (f"Status code: {response.status_code}")
pprint (response.json())
const SEARCH_URL = `${API_URL}/search`
const data = JSON.stringify(
{
'query': 'car accidents',
'index_id': INDEX_ID,
'search_options': ['visual', 'conversation'],
'operator': 'and'
})
const config = {
method: 'post',
url: SEARCH_URL,
headers: headers,
data: data
}
const resp = await axios(config)
const response = await resp.data
console.log(`Status code: ${resp.status}`)
console.log(response)
The example output below was truncated for brevity:
Status code: 200
{
"search_pool": {
"total_count": 13,
"total_duration": 8731,
"index_id": "639961c9e219c90227c371a2"
},
"data": [
{
"score": 76.79,
"start": 420.66,
"end": 430.23,
"metadata": [
{
"type": "conversation",
"text": "The safety car has gone, the lights gone green and there's a big crash at the back and that is the Alfa Romeo, certainly Antonio, joven Nazi was involved in that skirmish as well."
},
{
"type": "visual"
}
],
"video_id": "639963a1ce36463e0199c8c7",
"confidence": "medium",
"thumbnail_url": "https://project-one-thumbnail.s3.us-west-2.amazonaws.com/639963a1ce36463e0199c8c7/421.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYRWJPOVHXE5SJ77T%2F20221222%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221222T171955Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=4af3e7756eceb77239d996f6be0d7bd98c43a2fa534427c2f68d52ae0ee33ab4",
"modules": [
{
"type": "conversation",
"confidence": "medium"
},
{
"type": "visual",
"confidence": "low"
}
]
},
{
"score": 58.99,
"start": 665.745,
"end": 676.795,
"metadata": [
{
"type": "conversation",
"text": "That was an epic battle and bravo take a bow and a round of applause to go with it for both drivers there for what was as hard racing as you could possibly get without contact."
},
{
"type": "visual"
}
],
"video_id": "6399637ace36463e0199c8c6",
"confidence": "low",
"thumbnail_url": "https://project-one-thumbnail.s3.us-west-2.amazonaws.com/6399637ace36463e0199c8c6/666.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYRWJPOVHXE5SJ77T%2F20221222%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221222T171955Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=47d05aec72e9ce45d4ea06859762ba1957d5d1b18bec80e10fb328708cd0b142",
"modules": [
{
"type": "conversation",
"confidence": "low"
},
{
"type": "visual",
"confidence": "low"
}
]
}
],
"page_info": {
"limit_per_page": 10,
"total_results": 2,
"page_expired_at": "2022-12-22T17:19:55Z"
}
}
Conversation and text in video
The following example combines conversation
and text_in_video
, using the logical OR
operator to specify that the API should return the results for which any source of information matches:
SEARCH_URL = f"{API_URL}/search"
data = {
"query": "scoring a goal",
"index_id": INDEX_ID,
"search_options": ["conversation", "text_in_video"],
"operator": "or"
}
response = requests.post(SEARCH_URL, headers=headers, json=data)
print (f"Status code: {response.status_code}")
pprint (response.json())
const SEARCH_URL = `${API_URL}/search`
const data = JSON.stringify(
{
'query': 'scoring a goal',
'index_id': INDEX_ID,
'search_options': ['conversation', 'text_in_video'],
'operator': 'or'
})
const config = {
method: 'post',
url: SEARCH_URL,
headers: headers,
data: data
}
const resp = await axios(config)
const response = await resp.data
console.log(`Status code: ${resp.status}`)
console.log(response)
The example output below was truncated for brevity:
Status code: 200
{
"search_pool": {
"total_count": 13,
"total_duration": 8731,
"index_id": "639961c9e219c90227c371a2"
},
"data": [
{
"score": 69.72,
"start": 430,
"end": 433,
"metadata": [
{
"type": "text_in_video",
"text": "Messi scores a goal similar to the Maradona's \"Goal of the Century\" ( vs Getafe in 2007)"
}
],
"video_id": "639963d8ce36463e0199c8ca",
"confidence": "low",
"thumbnail_url": "https://project-one-thumbnail.s3.us-west-2.amazonaws.com/639963d8ce36463e0199c8ca/431.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYRWJPOVHXE5SJ77T%2F20221222%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221222T172228Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=378451b287886db8a5b0e97de512749a0beee7f4b7a6818afcc67928e23a59cb",
"modules": [
{
"type": "text_in_video",
"confidence": "low"
}
]
},
{
"score": 69.72,
"start": 597,
"end": 621,
"metadata": [
{
"type": "text_in_video",
"text": "But Lucas Moura scores a hat-trick in second-half (last goal at the 96th minute) and qualify Tottenham for the 2019 UCL final"
}
],
"video_id": "639963d8ce36463e0199c8ca",
"confidence": "low",
"thumbnail_url": "https://project-one-thumbnail.s3.us-west-2.amazonaws.com/639963d8ce36463e0199c8ca/598.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYRWJPOVHXE5SJ77T%2F20221222%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221222T172228Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=f81cdc5f446a20754d4c9c5e0abb69f7643b7105e56f014a3b88106ad154e674",
"modules": [
{
"type": "text_in_video",
"confidence": "low"
}
]
},
{
"score": 62.33,
"start": 271.1,
"end": 311.64,
"metadata": [
{
"type": "conversation",
"text": " Been some something special for his hat trick goal last. Well, I'll tell you what, you're not gonna see. Much better goals than that. What a hat trick. And what a third goal down. But it's the moment of magic that real Madrid had been waiting for his way, way on side."
}
],
"video_id": "639963afce36463e0199c8c8",
"confidence": "low",
"thumbnail_url": "https://project-one-thumbnail.s3.us-west-2.amazonaws.com/639963afce36463e0199c8c8/272.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYRWJPOVHXE5SJ77T%2F20221222%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221222T172228Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=5a33f9db9ed31bdd87e5aa5a106ef3c80791a078b8856bf88a1b3c290a05ce73",
"modules": [
{
"type": "conversation",
"confidence": "low"
}
]
}
],
"page_info": {
"limit_per_page": 10,
"total_results": 21,
"page_expired_at": "2022-12-22T17:22:28Z",
"next_page_token": "85277e49-59ea-4a13-ab11-d974a10d0d31-1"
}
}
The following example combines convesation
and text_in_video
, using the logical AND
operator to specify that the API should return only the results for which all sources of information match:
SEARCH_URL = f"{API_URL}/search"
data = {
"query": "scoring a goal",
"index_id": INDEX_ID,
"search_options": ["conversation", "text_in_video"],
"operator": "and"
}
response = requests.post(SEARCH_URL, headers=headers, json=data)
print (f"Status code: {response.status_code}")
pprint (response.json())
const SEARCH_URL = `${API_URL}/search`
const data = JSON.stringify(
{
'query': 'scoring a goal',
'index_id': INDEX_ID,
'search_options': ['conversation', 'text_in_video'],
'operator': 'and'
})
const config = {
method: 'post',
url: SEARCH_URL,
headers: headers,
data: data
}
const resp = await axios(config)
const response = await resp.data
console.log(`Status code: ${resp.status}`)
console.log(response)
The example output below was truncated for brevity:
Status code: 200
{'conversation_option': 'semantic',
'data': [{'confidence': 'high',
'end': 489.06,
'metadata': [{'text': "We don't care about the goalkeeper who he is "
'away from 234. Wonderful, wonderful, '
'wonderful. How good is he? A near '
'supernatural goal from Lionel messi. He is '
'just brilliant.',
'type': 'conversation'},
{'text': '22 - WONDER GOAL AGAINST BIGGEST COUNTRY '
'RIVAL',
'type': 'text_in_video'}],
'score': 96.26,
'start': 469.58,
'thumbnail_url': "https://project-one-thumbnail.s3.us-west-2.amazonaws.com/639963afce36463e0199c8c8/272.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYRWJPOVHXE5SJ77T%2F20221222%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221222T172228Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=5a33f9db9ed31bdd87e5aa5a106ef3c80791a078b8856bf88a1b3c290a05ce73',
'modules': [
{
'type': 'conversation',
'confidence': 'high'
},
{
'type': 'text_in_video',
'confidence': 'high'
}
]
'video_id': '62b3ee6cd01d61be020682f1'}],
'page_info': {'limit_per_page': 10,
'page_expired_at': '2022-06-23T05:01:26Z',
'total_results': 1},
'query': 'goal',
'search_options': ['conversation', 'text_in_video'],
'search_pool': {'index_id': '62b3ed745bf1be7a70989db4',
'total_count': 6,
'total_duration': 3971},
'type': 'search_create'}
Conversation, text in video, and visual
The following example combines conversation
, text_in_video
, and visual
, using the logical OR
operator to specify that the API should return the results for which any source of information matches:
SEARCH_URL = f"{API_URL}/search"
data = {
"query": "scoring a goal",
"index_id": INDEX_ID,
"search_options": ["conversation", "text_in_video", "visual"],
"operator": "or"
}
response = requests.post(SEARCH_URL, headers=headers, json=data)
print (f"Status code: {response.status_code}")
pprint (response.json())
const SEARCH_URL = `${API_URL}/search`
const data = JSON.stringify(
{
'query': 'scoring a goal',
'index_id': INDEX_ID,
'search_options': ['conversation', 'text_in_video', 'visual'],
'operator': 'or'
})
const config = {
method: 'post',
url: SEARCH_URL,
headers: headers,
data: data
}
const resp = await axios(config)
const response = await resp.data
console.log(`Status code: ${resp.status}`)
console.log(response)
The example output below was truncated for brevity:
Status code: 200
{
"search_pool": {
"total_count": 13,
"total_duration": 8731,
"index_id": "639961c9e219c90227c371a2"
},
"data": [
{
"score": 87,
"start": 611.8125,
"end": 614.84375,
"metadata": [
{
"type": "visual"
},
{
"type": "text_in_video",
"text": "But Lucas Moura scores a hat-trick in second-half (last goal at the 96th minute) and qualify Tottenham for the 2019 UCL final"
}
],
"video_id": "639963d8ce36463e0199c8ca",
"confidence": "high",
"thumbnail_url": "https://project-one-thumbnail.s3.us-west-2.amazonaws.com/639963d8ce36463e0199c8ca/612.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYRWJPOVHXE5SJ77T%2F20221223%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221223T060500Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=9df3f1eeb5a1620e871e82fed4c8af9b024ff6576de0ac8e40b6071739683a82",
"modules": [
{
"type": "visual",
"confidence": "high"
},
{
"type": "text_in_video",
"confidence": "low"
}
]
},
{
"score": 86.03,
"start": 468.0625,
"end": 472.21875,
"metadata": [
{
"type": "visual"
}
],
"video_id": "639963d8ce36463e0199c8ca",
"confidence": "high",
"thumbnail_url": "https://project-one-thumbnail.s3.us-west-2.amazonaws.com/639963d8ce36463e0199c8ca/469.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYRWJPOVHXE5SJ77T%2F20221223%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221223T060500Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=decf7209d4103dc467a2ee78e90ff9a4a95cc1c3883d1271e646381d0943e9fe",
"modules": [
{
"type": "visual",
"confidence": "high"
}
]
},
{
"score": 85.98,
"start": 416.96875,
"end": 436.34375,
"metadata": [
{
"type": "visual"
}
],
"video_id": "639963bbce36463e0199c8c9",
"confidence": "high",
"thumbnail_url": "https://project-one-thumbnail.s3.us-west-2.amazonaws.com/639963bbce36463e0199c8c9/417.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYRWJPOVHXE5SJ77T%2F20221223%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221223T060500Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=3748b01e51f319b13b6e2def20a2dc6264451a061da05474e41087ed58879e36",
"modules": [
{
"type": "visual",
"confidence": "high"
}
]
}
],
"page_info": {
"limit_per_page": 10,
"total_results": 469,
"page_expired_at": "2022-12-23T06:05:00Z",
"next_page_token": "2b01e928-fe71-41b0-b672-9667f43fa013-1"
}
}
The following example combines conversation
, text_in_video
, and visual
, using the logical AND
operator to specify that the API should return only the results for which all sources of information match:
SEARCH_URL = f"{API_URL}/search"
data = {
"query": "scoring a goal",
"index_id": INDEX_ID,
"search_options": ["conversation", "text_in_video", "visual"],
"operator": "and"
}
response = requests.post(SEARCH_URL, headers=headers, json=data)
print (f"Status code: {response.status_code}")
pprint (response.json())
const SEARCH_URL = `${API_URL}/search`
const data = JSON.stringify(
{
'query': 'scoring a goal',
'index_id': INDEX_ID,
'search_options': ['conversation', 'text_in_video', 'visual'],
'operator': 'and'
})
const config = {
method: 'post',
url: SEARCH_URL,
headers: headers,
data: data
}
const resp = await axios(config)
const response = await resp.data
console.log(`Status code: ${resp.status}`)
console.log(response)
The example output below was truncated for brevity:
Status code: 200
{'conversation_option': 'semantic',
'data': [{'confidence': 'high',
'end': 482,
'metadata': [{'type': 'visual'},
{'text': "We don't care about the goalkeeper who he is "
'away from 234. Wonderful, wonderful, '
'wonderful. How good is he? A near '
'supernatural goal from Lionel messi. He is '
'just brilliant.',
'type': 'conversation'},
{'text': '22 - WONDER GOAL AGAINST BIGGEST COUNTRY '
'RIVAL',
'type': 'text_in_video'}],
'thumbnail_url": "https://project-one-thumbnail.s3.us-west-2.amazonaws.com/639963d8ce36463e0199c8ca/469.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYRWJPOVHXE5SJ77T%2F20221223%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20221223T060500Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=decf7209d4103dc467a2ee78e90ff9a4a95cc1c3883d1271e646381d0943e9fe',
'modules': [
{
'type': 'visual',
'confidence': 'high'
},
{
'type': 'visual',
'confidence': 'medium'
},
{
'type': 'text_in_video',
'confidence': 'medium'
},
]
'score': 100.46,
'start': 470,
'video_id': '62b3ee6cd01d61be020682f1'}],
'page_info': {'limit_per_page': 10,
'page_expired_at': '2022-06-23T05:03:32Z',
'total_results': 1},
'query': 'goal',
'search_options': ['conversation', 'text_in_video', 'visual'],
'search_pool': {'index_id': '62b3ed745bf1be7a70989db4',
'total_count': 6,
'total_duration': 3971},
}
Pagination
This endpoint supports pagination. For details, see the Pagination > Search results page.
Filtering
This endpoint supports filtering. For details, see the Filtering > Search results page.
Sorting
This endpoint supports sorting. For details, see the Sorting > Search results page.
Grouping and ungrouping
This endpoint allows you to group or ungroup your search results based on the unique identifiers of the videos. For details, see the Grouping and ungrouping page.
Updated over 1 year ago