File tree Expand file tree Collapse file tree 3 files changed +56
-10
lines changed
memories/textual/tree_text_memory/retrieve Expand file tree Collapse file tree 3 files changed +56
-10
lines changed Original file line number Diff line number Diff line change @@ -928,6 +928,26 @@ def search_by_embedding(
928928
929929 return records
930930
931+ def search_by_fulltext (
932+ self ,
933+ query_words : list [str ],
934+ top_k : int = 10 ,
935+ scope : str | None = None ,
936+ status : str | None = None ,
937+ threshold : float | None = None ,
938+ search_filter : dict | None = None ,
939+ user_name : str | None = None ,
940+ filter : dict | None = None ,
941+ knowledgebase_ids : list [str ] | None = None ,
942+ tsquery_config : str | None = None ,
943+ ** kwargs ,
944+ ) -> list [dict ]:
945+ """
946+ TODO: 实现 Neo4j 的关键词检索, 以兼容 TreeTextMemory 的 keyword/fulltext 召回路径.
947+ 目前先返回空列表, 避免切换到 Neo4j 后因缺失方法导致运行时报错.
948+ """
949+ return []
950+
931951 def get_by_metadata (
932952 self ,
933953 filters : list [dict [str , Any ]],
Original file line number Diff line number Diff line change @@ -382,6 +382,26 @@ def search_by_embedding(
382382
383383 return filtered_results
384384
385+ def search_by_fulltext (
386+ self ,
387+ query_words : list [str ],
388+ top_k : int = 10 ,
389+ scope : str | None = None ,
390+ status : str | None = None ,
391+ threshold : float | None = None ,
392+ search_filter : dict | None = None ,
393+ user_name : str | None = None ,
394+ filter : dict | None = None ,
395+ knowledgebase_ids : list [str ] | None = None ,
396+ tsquery_config : str | None = None ,
397+ ** kwargs ,
398+ ) -> list [dict ]:
399+ """
400+ TODO: 实现 Neo4j Community 的关键词检索, 以兼容 TreeTextMemory 的 keyword/fulltext 召回路径.
401+ 目前先返回空列表, 避免切换到 Neo4j 后因缺失方法导致运行时报错.
402+ """
403+ return []
404+
385405 def _normalize_date_string (self , date_str : str ) -> str :
386406 """
387407 Normalize date string to ISO 8601 format for Neo4j datetime() function.
Original file line number Diff line number Diff line change @@ -511,16 +511,22 @@ def _retrieve_from_keyword(
511511
512512 id_to_score : dict [str , float ] = {}
513513 for scope in scopes :
514- hits = self .graph_store .search_by_fulltext (
515- query_words = tsquery_terms ,
516- top_k = top_k * 2 ,
517- status = "activated" ,
518- scope = scope ,
519- search_filter = None ,
520- filter = search_filter ,
521- user_name = user_name ,
522- tsquery_config = "jiebaqry" ,
523- )
514+ try :
515+ hits = self .graph_store .search_by_fulltext (
516+ query_words = tsquery_terms ,
517+ top_k = top_k * 2 ,
518+ status = "activated" ,
519+ scope = scope ,
520+ search_filter = None ,
521+ filter = search_filter ,
522+ user_name = user_name ,
523+ tsquery_config = "jiebaqry" ,
524+ )
525+ except Exception as e :
526+ logger .warning (
527+ f"[PATH-KEYWORD] search_by_fulltext failed, scope={ scope } , user_name={ user_name } "
528+ )
529+ hits = []
524530 for h in hits or []:
525531 hid = str (h .get ("id" ) or "" ).strip ().strip ("'\" " )
526532 if not hid :
You can’t perform that action at this time.
0 commit comments