Skip to content

issues about VectorCypherRetriever #397

@KaitouKK

Description

@KaitouKK

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions