From c6458c6ec144e4660a9ecaad9245842c2d6eeca0 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 4 Sep 2023 20:44:31 +0700 Subject: [PATCH] add score to full text search --- tubearchivist/api/src/search_processor.py | 7 ++++++- tubearchivist/static/script.js | 9 +++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tubearchivist/api/src/search_processor.py b/tubearchivist/api/src/search_processor.py index b180486e..63218e4b 100644 --- a/tubearchivist/api/src/search_processor.py +++ b/tubearchivist/api/src/search_processor.py @@ -53,7 +53,12 @@ class SearchProcess: if index == "ta_subtitle": processed = self._process_subtitle(result) - processed.update({"_index": index}) + processed.update( + { + "_index": index, + "_score": round(result.get("_score", 0), 2), + } + ) return processed diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js index 03984b29..f7375b85 100644 --- a/tubearchivist/static/script.js +++ b/tubearchivist/static/script.js @@ -1147,12 +1147,13 @@ function createFulltext(fullText) {
+
+

${fullText.subtitle_channel}

+

${fullText.title}

+

${subtitle_start} - ${subtitle_end}

${fullText.subtitle_line}

-
-

${fullText.subtitle_channel}

-

${fullText.title}

-
+ Score: ${fullText._score}
`; const fullTextDiv = document.createElement('div');