Skip to content

Commit

Permalink
upgrade to support Neo4j 4.4
Browse files Browse the repository at this point in the history
- limit the indexes query to ignore non-BTREE indexes
- replaced the deprecated "db.indexes()" function call
- renamed get_indexes function to get_btree_indexes
  • Loading branch information
AustinSMueller committed May 11, 2023
1 parent 4ad022d commit d32d318
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@
BATCH_SIZE = 1000


def get_indexes(session):
def get_btree_indexes(session):
"""
Queries the database to get all existing indexes
:param session: the current neo4j transaction session
:return: A set of tuples representing all existing indexes in the database
"""
command = "call db.indexes()"
command = "SHOW INDEXES"
result = session.run(command)
indexes = set()
for r in result:
indexes.add(format_as_tuple(r["labelsOrTypes"][0], r["properties"]))
if r["type"] == "BTREE":
indexes.add(format_as_tuple(r["labelsOrTypes"][0], r["properties"]))
return indexes


def format_as_tuple(node_name, properties):
"""
Format index info as a tuple
Expand Down Expand Up @@ -989,7 +989,7 @@ def create_indexes(self, session):
properties file
:param session: the current neo4j transaction session
"""
existing = get_indexes(session)
existing = get_btree_indexes(session)
# Create indexes from "id_fields" section of the properties file
ids = self.schema.props.id_fields
for node_name in ids:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pyyaml
neo4j==4.2.*
neo4j==4.4.*
boto3
requests
elasticsearch==7.13.*
Expand Down

0 comments on commit d32d318

Please sign in to comment.