Add support for channel-specific filtering in subtitle search (#1096)
* Add channel filter support to subtitle search queries * Update search examples to include channel filter option --------- Co-authored-by: Dmitry Sprozin <dysprozin@gmail.com>
This commit is contained in:
parent
a30528f358
commit
20ac5ef807
|
|
@ -113,6 +113,7 @@ class SearchParser:
|
|||
"index": "ta_subtitle",
|
||||
"lang": [],
|
||||
"source": [],
|
||||
"channel": [],
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -345,6 +346,22 @@ class QueryBuilder:
|
|||
"""build query for fulltext search"""
|
||||
must_list = []
|
||||
|
||||
if (channel := self.query_map.get("channel")) is not None:
|
||||
must_list.append(
|
||||
{
|
||||
"multi_match": {
|
||||
"query": channel,
|
||||
"type": "bool_prefix",
|
||||
"fuzziness": self._get_fuzzy(),
|
||||
"operator": "and",
|
||||
"fields": [
|
||||
"subtitle_channel",
|
||||
"subtitle_channel.keyword",
|
||||
],
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (term := self.query_map.get("term")) is not None:
|
||||
must_list.append(
|
||||
{
|
||||
|
|
|
|||
|
|
@ -104,6 +104,10 @@ const SearchExampleQueries = () => {
|
|||
auto-generated subtitles only, or <i>user</i> to search through user-uploaded
|
||||
subtitles only
|
||||
</li>
|
||||
<li>
|
||||
<span>channel:</span> — limit subtitle search to a specific channel name (for
|
||||
example: <code>full:javascript channel:corey schafer</code>)
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
|||
Loading…
Reference in New Issue