diff --git a/tubearchivist/home/forms.py b/tubearchivist/home/forms.py index f85392d..e19e3c6 100644 --- a/tubearchivist/home/forms.py +++ b/tubearchivist/home/forms.py @@ -116,6 +116,21 @@ class PlaylistSearchForm(forms.Form): ) +class MultiSearchForm(forms.Form): + """multi search form for /search/""" + + searchInput = forms.CharField( + label="", + widget=forms.TextInput( + attrs={ + "autocomplete": "off", + "oninput": "searchMulti(this.value)", + "autofocus": True, + } + ), + ) + + class AddToQueueForm(forms.Form): """text area form to add to downloads""" diff --git a/tubearchivist/home/src/searching.py b/tubearchivist/home/src/searching.py index 535dbb2..b94d056 100644 --- a/tubearchivist/home/src/searching.py +++ b/tubearchivist/home/src/searching.py @@ -184,14 +184,23 @@ class SearchForm: "query": { "multi_match": { "query": search_query, + "type": "bool_prefix", + "operator": "and", + "fuzziness": "auto", "fields": [ - "title", - "tags", "category", - "channel_name", "channel_description", - "playlist_name", + "channel_name._2gram", + "channel_name._3gram", + "channel_name.search_as_you_type", "playlist_description", + "playlist_name._2gram", + "playlist_name._3gram", + "playlist_name.search_as_you_type", + "tags", + "title._2gram", + "title._3gram", + "title.search_as_you_type", ], } }, @@ -208,13 +217,14 @@ class SearchForm: video_results = [] channel_results = [] playlist_results = [] - for result in search_results: - if result["_index"] == "ta_video": - video_results.append(result) - elif result["_index"] == "ta_channel": - channel_results.append(result) - elif result["_index"] == "ta_playlist": - playlist_results.append(result) + if search_results: + for result in search_results: + if result["_index"] == "ta_video": + video_results.append(result) + elif result["_index"] == "ta_channel": + channel_results.append(result) + elif result["_index"] == "ta_playlist": + playlist_results.append(result) all_results = { "video_results": video_results, diff --git a/tubearchivist/home/templates/home/search.html b/tubearchivist/home/templates/home/search.html new file mode 100644 index 0000000..d109263 --- /dev/null +++ b/tubearchivist/home/templates/home/search.html @@ -0,0 +1,29 @@ +{% extends "home/base.html" %} +{% block content %} +
No videos found.
+No channels found.
+No playlists found.
+