Skip to content

Commit 7378cd9

Browse files
committed
Adds the option to change the DB with retrieve_vector_index_info and retrieve_fulltext_index_info
1 parent 59d74bb commit 7378cd9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/neo4j_graphrag/indexes.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,11 @@ def _sort_by_index_name(
608608

609609

610610
def retrieve_vector_index_info(
611-
driver: neo4j.Driver, index_name: str, label_or_type: str, embedding_property: str
611+
driver: neo4j.Driver,
612+
index_name: str,
613+
label_or_type: str,
614+
embedding_property: str,
615+
neo4j_database: Optional[str] = None,
612616
) -> Optional[neo4j.Record]:
613617
"""
614618
Check if a vector index exists in a Neo4j database and return its
@@ -621,6 +625,9 @@ def retrieve_vector_index_info(
621625
of the index.
622626
embedding_property (str): The name of the property containing the
623627
embeddings.
628+
neo4j_database (Optional[str]): The name of the Neo4j database.
629+
If not provided, this defaults to the server's default database ("neo4j" by default)
630+
(`see reference to documentation <https://neo4j.com/docs/operations-manual/current/database-administration/#manage-databases-default>`_).
624631
625632
Returns:
626633
Optional[Dict[str, Any]]:
@@ -640,6 +647,7 @@ def retrieve_vector_index_info(
640647
"label_or_type": label_or_type,
641648
"embedding_property": embedding_property,
642649
},
650+
database_=neo4j_database,
643651
)
644652
index_information = _sort_by_index_name(result.records, index_name)
645653
if len(index_information) > 0:
@@ -653,6 +661,7 @@ def retrieve_fulltext_index_info(
653661
index_name: str,
654662
label_or_type: str,
655663
text_properties: List[str] = [],
664+
neo4j_database: Optional[str] = None,
656665
) -> Optional[neo4j.Record]:
657666
"""
658667
Check if a full text index exists in a Neo4j database and return its
@@ -664,6 +673,9 @@ def retrieve_fulltext_index_info(
664673
label_or_type (str): The label (for nodes) or type (for relationships)
665674
of the index.
666675
text_properties (List[str]): The names of the text properties indexed.
676+
neo4j_database (Optional[str]): The name of the Neo4j database.
677+
If not provided, this defaults to the server's default database ("neo4j" by default)
678+
(`see reference to documentation <https://neo4j.com/docs/operations-manual/current/database-administration/#manage-databases-default>`_).
667679
668680
Returns:
669681
Optional[Dict[str, Any]]:
@@ -683,6 +695,7 @@ def retrieve_fulltext_index_info(
683695
"label_or_type": label_or_type,
684696
"text_properties": text_properties,
685697
},
698+
database_=neo4j_database,
686699
)
687700
index_information = _sort_by_index_name(result.records, index_name)
688701
if len(index_information) > 0:

0 commit comments

Comments
 (0)