From d460b0947a8115c45c33db92d5eed05f3318fe58 Mon Sep 17 00:00:00 2001 From: LUIS NOVO Date: Wed, 13 Nov 2024 19:03:03 -0300 Subject: [PATCH] wip - remote content from text search until can do partial search --- migrations/4.surrealql | 4 ++-- pages/3_🔍_Ask_and_Search.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/migrations/4.surrealql b/migrations/4.surrealql index f89531e..7744087 100644 --- a/migrations/4.surrealql +++ b/migrations/4.surrealql @@ -63,13 +63,13 @@ DEFINE FUNCTION IF NOT EXISTS fn::text_search($query_text: string, $match_count: let $note_results = array::union($note_title_search, $note_content_search ); let $final_results = array::union($source_results, $note_results ); - RETURN (select id, parent_id, title, math::max(relevance) as relevance, - array::flatten(content) as matches + RETURN (select id, parent_id, title, math::max(relevance) as relevance from $final_results where id is not None group by id, parent_id, title ORDER BY relevance DESC LIMIT $match_count); }; + REMOVE FUNCTION IF EXISTS fn::vector_search; DEFINE FUNCTION IF NOT EXISTS fn::vector_search($query: array, $match_count: int, $sources: bool, $show_notes: bool, $min_similarity: float) { diff --git a/pages/3_🔍_Ask_and_Search.py b/pages/3_🔍_Ask_and_Search.py index 7956737..fe54ec8 100644 --- a/pages/3_🔍_Ask_and_Search.py +++ b/pages/3_🔍_Ask_and_Search.py @@ -42,9 +42,10 @@ def results_card(item): st.markdown( f"[{score:.2f}] **[{item['title']}](/?object_id={item['parent_id']})**" ) - with st.expander("Matches"): - for match in item["matches"]: - st.markdown(match) + if "matches" in item: + with st.expander("Matches"): + for match in item["matches"]: + st.markdown(match) with ask_tab: