-
Notifications
You must be signed in to change notification settings - Fork 127
Description
I'm using the neo4j_graphrag Python package to build a GraphRAG knowledge base. I'm encountering an issue where my retrieval query returns multiple results even when setting top_k=1. Here's the relevant code:
INDEX_NAME = "Task" retrieval_query = f"MATCH p=(n:Task)-->(o:Operation)-->(e:Element) WHERE \"{tmp_goal}\" CONTAINS e.name RETURN score, n.id ORDER BY score DESC" retriever = VectorCypherRetriever(driver, INDEX_NAME, embedder=embedder, retrieval_query=retrieval_query) pattern = r'<Record n\.id=(\d+)>' tmp_result = retriever.search(query_text=tmp_goal, top_k=1).items print(tmp_result)
My goal is to retrieve only the most relevant Task node by setting top_k=1, but the output still contains multiple results. Could you help explain why this is happening and how to fix it?