Skip to content

Adds the option to change the DB with retrieve_vector_index_info and retrieve_fulltext_index_info #356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/neo4j_graphrag/indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,11 @@ def _sort_by_index_name(


def retrieve_vector_index_info(
driver: neo4j.Driver, index_name: str, label_or_type: str, embedding_property: str
driver: neo4j.Driver,
index_name: str,
label_or_type: str,
embedding_property: str,
neo4j_database: Optional[str] = None,
) -> Optional[neo4j.Record]:
"""
Check if a vector index exists in a Neo4j database and return its
Expand All @@ -621,6 +625,9 @@ def retrieve_vector_index_info(
of the index.
embedding_property (str): The name of the property containing the
embeddings.
neo4j_database (Optional[str]): The name of the Neo4j database.
If not provided, this defaults to the server's default database ("neo4j" by default)
(`see reference to documentation <https://neo4j.com/docs/operations-manual/current/database-administration/#manage-databases-default>`_).

Returns:
Optional[Dict[str, Any]]:
Expand All @@ -640,6 +647,7 @@ def retrieve_vector_index_info(
"label_or_type": label_or_type,
"embedding_property": embedding_property,
},
database_=neo4j_database,
)
index_information = _sort_by_index_name(result.records, index_name)
if len(index_information) > 0:
Expand All @@ -653,6 +661,7 @@ def retrieve_fulltext_index_info(
index_name: str,
label_or_type: str,
text_properties: List[str] = [],
neo4j_database: Optional[str] = None,
) -> Optional[neo4j.Record]:
"""
Check if a full text index exists in a Neo4j database and return its
Expand All @@ -664,6 +673,9 @@ def retrieve_fulltext_index_info(
label_or_type (str): The label (for nodes) or type (for relationships)
of the index.
text_properties (List[str]): The names of the text properties indexed.
neo4j_database (Optional[str]): The name of the Neo4j database.
If not provided, this defaults to the server's default database ("neo4j" by default)
(`see reference to documentation <https://neo4j.com/docs/operations-manual/current/database-administration/#manage-databases-default>`_).

Returns:
Optional[Dict[str, Any]]:
Expand All @@ -683,6 +695,7 @@ def retrieve_fulltext_index_info(
"label_or_type": label_or_type,
"text_properties": text_properties,
},
database_=neo4j_database,
)
index_information = _sort_by_index_name(result.records, index_name)
if len(index_information) > 0:
Expand Down