From d32d318fb7f96f9752d563820fb0435afb1f7243 Mon Sep 17 00:00:00 2001 From: Austin Mueller Date: Thu, 11 May 2023 15:04:57 -0400 Subject: [PATCH] upgrade to support Neo4j 4.4 - limit the indexes query to ignore non-BTREE indexes - replaced the deprecated "db.indexes()" function call - renamed get_indexes function to get_btree_indexes --- data_loader.py | 10 +++++----- requirements.txt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data_loader.py b/data_loader.py index 475eda04..e5db28fc 100755 --- a/data_loader.py +++ b/data_loader.py @@ -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 @@ -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: diff --git a/requirements.txt b/requirements.txt index afe223ec..71b38a67 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ pyyaml -neo4j==4.2.* +neo4j==4.4.* boto3 requests elasticsearch==7.13.*