Skip to content

Commit 63290e4

Browse files
committed
Merge branch 'main' of https://github.com/video-db/videodb-python into ar/add-image-support
2 parents 30da85a + 7588bc4 commit 63290e4

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

videodb/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from videodb._constants import (
99
VIDEO_DB_API,
1010
MediaType,
11+
SearchType,
1112
SubtitleAlignment,
1213
SubtitleBorderStyle,
1314
SubtitleStyle,
@@ -32,6 +33,7 @@
3233
"SearchError",
3334
"play_stream",
3435
"MediaType",
36+
"SearchType",
3537
"SubtitleAlignment",
3638
"SubtitleBorderStyle",
3739
"SubtitleStyle",

videodb/_constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class MediaType:
1313

1414
class SearchType:
1515
semantic = "semantic"
16+
keyword = "keyword"
1617

1718

1819
class IndexType:

videodb/search.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def search_inside_video(
116116
search_data = self._connection.post(
117117
path=f"{ApiPath.video}/{video_id}/{ApiPath.search}",
118118
data={
119-
"type": SearchType.semantic,
119+
"index_type": SearchType.semantic,
120120
"query": query,
121121
"score_threshold": score_threshold
122122
or SemanticSearchDefaultValues.score_threshold,
@@ -137,7 +137,7 @@ def search_inside_collection(
137137
search_data = self._connection.post(
138138
path=f"{ApiPath.collection}/{collection_id}/{ApiPath.search}",
139139
data={
140-
"type": SearchType.semantic,
140+
"index_type": SearchType.semantic,
141141
"query": query,
142142
"score_threshold": score_threshold
143143
or SemanticSearchDefaultValues.score_threshold,
@@ -148,7 +148,35 @@ def search_inside_collection(
148148
return SearchResult(self._connection, **search_data)
149149

150150

151-
search_type = {SearchType.semantic: SemanticSearch}
151+
class KeywordSearch(Search):
152+
def __init__(self, _connection):
153+
self._connection = _connection
154+
155+
def search_inside_video(
156+
self,
157+
video_id: str,
158+
query: str,
159+
result_threshold: Optional[int] = None,
160+
score_threshold: Optional[int] = None,
161+
dynamic_score_percentage: Optional[int] = None,
162+
**kwargs,
163+
):
164+
search_data = self._connection.post(
165+
path=f"{ApiPath.video}/{video_id}/{ApiPath.search}",
166+
data={
167+
"index_type": SearchType.keyword,
168+
"query": query,
169+
"score_threshold": score_threshold,
170+
"result_threshold": result_threshold,
171+
},
172+
)
173+
return SearchResult(self._connection, **search_data)
174+
175+
def search_inside_collection(**kwargs):
176+
raise NotImplementedError("Keyword search will be implemented in the future")
177+
178+
179+
search_type = {SearchType.semantic: SemanticSearch, SearchType.keyword: KeywordSearch}
152180

153181

154182
class SearchFactory:

0 commit comments

Comments
 (0)