apoc.convert.Totree availability on Neo4J 5?

We were using Neo4j Aura with version 4.4 and now want to migrate our database to version 5. Previously, we used the procedure apoc.convert.toTree, but in the migration readiness report, it is marked as deprecated.

After reviewing the documentation for version 5, it states that apoc.convert.toTree has been replaced by apoc.paths.toJsonTree. However, when we executed the query CALL apoc.help('toJsonTree'); in the Aura console (version 5), it appears that the procedure is not available.

Can anyone assist with this issue?

@zil.darji

https://neo4j.com/docs/aura/classic/platform/apoc/ states

A subset of the APOC Core functions and procedures are pre-installed 
and available in Aura, as shown below:

and then lists the functions and procedures available and for which apoc.paths.toJsonTree is reported as not available

Hi @dana_canzano ,
Yes, the procedure apoc.paths.toJsonTree is not mentioned there. Can you please suggest another procedure or solution that I can use for the same purpose?

Hi @zil.darji we are reviewing apoc.paths.toJsonTree for inclusion into Aura. Unfortunately I don't have a timeline on this yet but will get back to you within the next few days.

1 Like

Thanks for the answer, Aman.
I am awaiting hearing back from you.

Hi @zil.darji thanks for holding on here. We will include apoc.paths.toJsonTree in the next Neo4j Calendar release in approximately a month's time.

You could also migrate now and carry on using apoc.convert.toTree. It will not be removed until we release Cypher 25, and make sure to change it to apoc.paths.toJsonTree as soon as the next release is available

Hi @zil.darji apoc.paths.toJsonTree is now available in Aura.

Yes, @aman.singh We have checked and it's working fine. Thanks

@aman.singh , We noticed that some response changes there for the same query. Please find the document for old and new queries with their responses.

Old Query:

"MATCH (nl:Nl{nl_id:2424})-[:NL_REFERS_TO_SOL]->(sl:Sol)<-[:RULE_BOOK_ISSUE_CONSISTS_OF_SOLS]-(rbi:Rule_Book_Issue)<-[:HAS_RULE_BOOK_ISSUE]-(rb:Rule_Book)
CALL {
  WITH rb
  MATCH path = (rbs:Rule_Book_Struct{rule_book_struct_id:""Rule Root Object""})-[:HAS_RULE_BOOK_STRUCT_CHILD*]->(rbsc:Rule_Book_Struct)<-[:RULE_BOOK_BELONGS_TO_STRUCT]-(prb:Rule_Book)-[:HAS_RULE_BOOK_CHILD*]->(rb)
  RETURN path
  UNION
  WITH rb
  MATCH path = (rbs:Rule_Book_Struct{rule_book_struct_id:""Rule Root Object""})-[:HAS_RULE_BOOK_STRUCT_CHILD*]->(rbsc:Rule_Book_Struct)<-[:RULE_BOOK_BELONGS_TO_STRUCT]-(rb)
  RETURN path
}
WITH collect(path) AS paths
CALL apoc.convert.toTree(paths) yield value
RETURN value"

Old query Response:

"[
  {
    ""value"": {
      ""_type"": ""Rule_Book_Struct"",
      ""_id"": 376,
      ""rule_book_struct_id"": ""Rule Root Object"",
      ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:376"",
      ""has_rule_book_struct_child"": [
        {
          ""_type"": ""Rule_Book_Struct"",
          ""_id"": 405,
          ""rule_book_struct_id"": ""NAT"",
          ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:405"",
          ""has_rule_book_struct_child.order_rule_book_struct"": 30,
          ""has_rule_book_struct_child.order"": 30,
          ""rule_book_struct_active"": true,
          ""has_rule_book_struct_child._id"": 21181,
          ""has_rule_book_struct_child._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:21181"",
          ""has_rule_book_struct_child"": [
            {
              ""_type"": ""Rule_Book_Struct"",
              ""_id"": 651,
              ""rule_book_struct_id"": ""DE"",
              ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:651"",
              ""has_rule_book_struct_child.order_rule_book_struct"": 20,
              ""has_rule_book_struct_child.order"": 20,
              ""rule_book_struct_active"": true,
              ""has_rule_book_struct_child._id"": 21451,
              ""has_rule_book_struct_child._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:21451"",
              ""has_rule_book_struct_child"": [
                {
                  ""_type"": ""Rule_Book_Struct"",
                  ""_id"": 803,
                  ""rule_book_struct_id"": ""DE_V"",
                  ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:803"",
                  ""has_rule_book_struct_child.order_rule_book_struct"": 20,
                  ""has_rule_book_struct_child.order"": 20,
                  ""rule_book_struct_active"": true,
                  ""has_rule_book_struct_child._id"": 21587,
                  ""has_rule_book_struct_child._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:21587"",
                  ""has_rule_book_struct_child"": [
                    {
                      ""_type"": ""Rule_Book_Struct"",
                      ""_id"": 872,
                      ""rule_book_struct_id"": ""DE_V_ORG"",
                      ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:872"",
                      ""has_rule_book_struct_child.order_rule_book_struct"": 20,
                      ""has_rule_book_struct_child.order"": 20,
                      ""rule_book_struct_active"": true,
                      ""has_rule_book_struct_child._id"": 21656,
                      ""rule_book_belongs_to_struct"": [
                        {
                          ""rule_book_active"": true,
                          ""_type"": ""Rule_Book"",
                          ""_id"": 5547,
                          ""rule_book_belongs_to_struct.order"": 50,
                          ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:5547"",
                          ""rule_book_belongs_to_struct.order_rule_book_in_struct"": 50,
                          ""rule_book_belongs_to_struct._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:24422"",
                          ""rule_book_id"": ""DE_FSAAKV"",
                          ""rule_book_belongs_to_struct._id"": 24422
                        }
                      ],
                      ""has_rule_book_struct_child._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:21656""
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  }
]"

New Query:

"MATCH (nl:Nl{nl_id:2424})-[:NL_REFERS_TO_SOL]->(sl:Sol)<-[:RULE_BOOK_ISSUE_CONSISTS_OF_SOLS]-(rbi:Rule_Book_Issue)<-[:HAS_RULE_BOOK_ISSUE]-(rb:Rule_Book)
CALL {
  WITH rb
  MATCH path = (rbs:Rule_Book_Struct{rule_book_struct_id:""Rule Root Object""})-[:HAS_RULE_BOOK_STRUCT_CHILD*]->(rbsc:Rule_Book_Struct)<-[:RULE_BOOK_BELONGS_TO_STRUCT]-(prb:Rule_Book)-[:HAS_RULE_BOOK_CHILD*]->(rb)
  RETURN path
  UNION
  WITH rb
  MATCH path = (rbs:Rule_Book_Struct{rule_book_struct_id:""Rule Root Object""})-[:HAS_RULE_BOOK_STRUCT_CHILD*]->(rbsc:Rule_Book_Struct)<-[:RULE_BOOK_BELONGS_TO_STRUCT]-(rb)
  RETURN path
}
WITH collect(path) AS paths
CALL apoc.paths.toJsonTree(paths) yield value
RETURN value"

New Query Response

"[
  {
    ""value"": {
      ""_type"": ""Rule_Book_Struct"",
      ""_id"": 376,
      ""rule_book_struct_id"": ""Rule Root Object"",
      ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:376"",
      ""has_rule_book_struct_child"": [
        {
          ""_type"": ""Rule_Book_Struct"",
          ""_id"": 405,
          ""rule_book_struct_id"": ""NAT"",
          ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:405"",
          ""has_rule_book_struct_child.order_rule_book_struct"": 30,
          ""has_rule_book_struct_child.order"": 30,
          ""rule_book_struct_active"": true,
          ""has_rule_book_struct_child._id"": 21181,
          ""has_rule_book_struct_child._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:21181"",
          ""has_rule_book_struct_child"": [
            {
              ""_type"": ""Rule_Book_Struct"",
              ""_id"": 651,
              ""rule_book_struct_id"": ""DE"",
              ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:651"",
              ""has_rule_book_struct_child.order_rule_book_struct"": 20,
              ""has_rule_book_struct_child.order"": 20,
              ""rule_book_struct_active"": true,
              ""has_rule_book_struct_child._id"": 21451,
              ""has_rule_book_struct_child._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:21451"",
              ""has_rule_book_struct_child"": [
                {
                  ""_type"": ""Rule_Book_Struct"",
                  ""_id"": 803,
                  ""rule_book_struct_id"": ""DE_V"",
                  ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:803"",
                  ""has_rule_book_struct_child.order_rule_book_struct"": 20,
                  ""has_rule_book_struct_child.order"": 20,
                  ""rule_book_struct_active"": true,
                  ""has_rule_book_struct_child._id"": 21587,
                  ""has_rule_book_struct_child._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:21587"",
                  ""has_rule_book_struct_child"": [
                    {
                      ""_type"": ""Rule_Book_Struct"",
                      ""_id"": 872,
                      ""rule_book_struct_id"": ""DE_V_ORG"",
                      ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:872"",
                      ""has_rule_book_struct_child.order_rule_book_struct"": 20,
                      ""has_rule_book_struct_child.order"": 20,
                      ""rule_book_struct_active"": true,
                      ""has_rule_book_struct_child._id"": 21656,
                      ""has_rule_book_struct_child._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:21656""
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  },
  {
    ""value"": {
      ""rule_book_active"": true,
      ""_type"": ""Rule_Book"",
      ""_id"": 5547,
      ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:5547"",
      ""rule_book_id"": ""DE_FSAAKV"",
      ""rule_book_belongs_to_struct"": [
        {
          ""_type"": ""Rule_Book_Struct"",
          ""_id"": 872,
          ""rule_book_struct_id"": ""DE_V_ORG"",
          ""rule_book_belongs_to_struct.order"": 50,
          ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:872"",
          ""rule_book_belongs_to_struct.order_rule_book_in_struct"": 50,
          ""rule_book_belongs_to_struct._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:24422"",
          ""rule_book_struct_active"": true,
          ""rule_book_belongs_to_struct._id"": 24422
        }
      ]
    }
  }
]"