mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-08 20:29:27 +00:00
add channel keyword search
This commit is contained in:
@@ -300,6 +300,7 @@ class QueryBuilder:
|
|||||||
|
|
||||||
exec_map = {
|
exec_map = {
|
||||||
"video": self._build_video,
|
"video": self._build_video,
|
||||||
|
"channel": self._build_channel,
|
||||||
}
|
}
|
||||||
|
|
||||||
build_must_list = exec_map[self.query_type]
|
build_must_list = exec_map[self.query_type]
|
||||||
@@ -350,3 +351,34 @@ class QueryBuilder:
|
|||||||
)
|
)
|
||||||
|
|
||||||
return must_list
|
return must_list
|
||||||
|
|
||||||
|
def _build_channel(self):
|
||||||
|
"""build query for channel"""
|
||||||
|
must_list = []
|
||||||
|
|
||||||
|
if (term := self.query_map.get("term")) is not None:
|
||||||
|
must_list.append(
|
||||||
|
{
|
||||||
|
"multi_match": {
|
||||||
|
"query": term,
|
||||||
|
"type": "bool_prefix",
|
||||||
|
"fuzziness": "auto",
|
||||||
|
"fields": [
|
||||||
|
"channel_description",
|
||||||
|
"channel_name._2gram",
|
||||||
|
"channel_name._3gram",
|
||||||
|
"channel_name.search_as_you_type",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (active := self.query_map.get("active")) is not None:
|
||||||
|
must_list.append({"term": {"channel_active": {"value": active}}})
|
||||||
|
|
||||||
|
if (active := self.query_map.get("subscribed")) is not None:
|
||||||
|
must_list.append(
|
||||||
|
{"term": {"channel_subscribed": {"value": active}}}
|
||||||
|
)
|
||||||
|
|
||||||
|
return must_list
|
||||||
|
|||||||
Reference in New Issue
Block a user