From 8d9b33bcb4a241c066825345b92724325b3f27fa Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 6 Jan 2026 22:48:08 +0700 Subject: [PATCH] improve playlist mapping, serializer, better none desc --- backend/appsettings/index_mapping.json | 74 +++++++++---------- backend/common/src/search_processor.py | 2 + .../config/management/commands/ta_startup.py | 2 +- backend/playlist/src/index.py | 5 +- 4 files changed, 44 insertions(+), 39 deletions(-) diff --git a/backend/appsettings/index_mapping.json b/backend/appsettings/index_mapping.json index 3b473189..3d0d3ad8 100644 --- a/backend/appsettings/index_mapping.json +++ b/backend/appsettings/index_mapping.json @@ -501,37 +501,9 @@ { "index_name": "playlist", "expected_map": { - "playlist_id": { - "type": "keyword" - }, - "playlist_description": { - "type": "text" - }, - "playlist_subscribed": { - "type": "boolean" - }, - "playlist_type": { - "type": "keyword" - }, "playlist_active": { "type": "boolean" }, - "playlist_name": { - "type": "text", - "analyzer": "english", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256, - "normalizer": "to_lower" - }, - "search_as_you_type": { - "type": "search_as_you_type", - "doc_values": false, - "max_shingle_size": 3 - } - } - }, "playlist_channel": { "type": "text", "fields": { @@ -545,15 +517,8 @@ "playlist_channel_id": { "type": "keyword" }, - "playlist_thumbnail": { - "type": "keyword" - }, - "playlist_last_refresh": { - "type": "date", - "format": "epoch_second" - }, - "playlist_sort_order": { - "type": "keyword" + "playlist_description": { + "type": "text" }, "playlist_entries": { "properties": { @@ -589,6 +554,41 @@ "type": "keyword" } } + }, + "playlist_id": { + "type": "keyword" + }, + "playlist_last_refresh": { + "type": "date", + "format": "epoch_second" + }, + "playlist_name": { + "type": "text", + "analyzer": "english", + "fields": { + "keyword": { + "type": "keyword", + "ignore_above": 256, + "normalizer": "to_lower" + }, + "search_as_you_type": { + "type": "search_as_you_type", + "doc_values": false, + "max_shingle_size": 3 + } + } + }, + "playlist_sort_order": { + "type": "keyword" + }, + "playlist_subscribed": { + "type": "boolean" + }, + "playlist_thumbnail": { + "type": "keyword" + }, + "playlist_type": { + "type": "keyword" } }, "expected_set": { diff --git a/backend/common/src/search_processor.py b/backend/common/src/search_processor.py index 02f71957..a866ab77 100644 --- a/backend/common/src/search_processor.py +++ b/backend/common/src/search_processor.py @@ -168,10 +168,12 @@ class SearchProcess: ) cache_root = EnvironmentSettings().get_cache_root() playlist_thumbnail = f"{cache_root}/playlists/{playlist_id}.jpg" + description = playlist_dict.get("playlist_description") playlist_dict.update( { "playlist_thumbnail": playlist_thumbnail, "playlist_last_refresh": playlist_last_refresh, + "playlist_description": description, } ) diff --git a/backend/config/management/commands/ta_startup.py b/backend/config/management/commands/ta_startup.py index f10be9b7..e0c8d16d 100644 --- a/backend/config/management/commands/ta_startup.py +++ b/backend/config/management/commands/ta_startup.py @@ -330,7 +330,7 @@ class Command(BaseCommand): desc="fix playlist description data type", query={"term": {"playlist_description": {"value": False}}}, script={ - "source": "ctx._source.playlist_description = null", + "source": "ctx._source.remove(playlist_description)", "lang": "painless", }, ) diff --git a/backend/playlist/src/index.py b/backend/playlist/src/index.py index 2f96ba8d..9322e01c 100644 --- a/backend/playlist/src/index.py +++ b/backend/playlist/src/index.py @@ -81,10 +81,13 @@ class YoutubePlaylist(YouTubeItem): "playlist_channel": self.youtube_meta["channel"], "playlist_channel_id": self.youtube_meta["channel_id"], "playlist_thumbnail": playlist_thumbnail, - "playlist_description": self.youtube_meta["description"] or None, "playlist_last_refresh": int(datetime.now().timestamp()), "playlist_type": "regular", } + if self.youtube_meta.get("description"): + self.json_data["playlist_description"] = self.youtube_meta[ + "description" + ] def _ensure_channel(self): """make sure channel is indexed"""