Skip to content
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

Add option to include direction of relations in apoc.convert.toTree #54

Closed
neo-technology-build-agent opened this issue Sep 1, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@neo-technology-build-agent
Copy link
Collaborator

Issue by mrveld94
Wednesday Sep 08, 2021 at 09:54 GMT
Originally opened as neo4j-contrib/neo4j-apoc-procedures#2199


The output of apoc.convert.toTree does not include the direction of the relations.

For example, consider the following path.
image

I can turn this path into a tree (with the pink node as root node) using the following query.

CALL apoc.convert.toTree(path, false) YIELD output RETURN output

This results in the following json.

{
  "_type": "Resource:prov__Entity:provone__Data",
  "uri": "urn:uuid:output_adaguc_Zmax_202108091550.h5",
  "prov__hadMember": [
    {
      "_type": "Resource:prov__Entity:prov__Collection",
      "uri": "urn:uuid:output_collection_Output_202108091550",
      "prov__wasDerivedFrom": [
        {
          "_type": "Resource:prov__Entity:prov__Collection",
          "uri": "urn:uuid:input_collection_Model_202108091550"
        },
        {
          "_type": "Resource:prov__Entity:prov__Collection",
          "uri": "urn:uuid:input_collection_Radar_202108091550"
        },
        {
          "_type": "Resource:prov__Entity:prov__Collection",
          "uri": "urn:uuid:input_collection_IVS_202108091550"
        }
      ]
    }
  ]
}

Looking at this output I cannot determine if urn:uuid:output_adaguc_Zmax_202108091550.h5 <prov__hadMember urn:uuid:output_collection_Output_202108091550 or if urn:uuid:output_adaguc_Zmax_202108091550.h5 prov__hadMember> urn:uuid:output_collection_Output_202108091550.
In other words I cannot determine which entity is a member of which.

I would like to see an option in apoc.convert.toTree, which would return the direction of the relations. For example by using the following query.

CALL apoc.convert.toTree(path, false, { includeDirection: true }) YIELD output RETURN output

Which would return something like this.

{
  "_type": "Resource:prov__Entity:provone__Data",
  "uri": "urn:uuid:output_adaguc_Zmax_202108091550.h5",
  "<prov__hadMember": [
    {
      "_type": "Resource:prov__Entity:prov__Collection",
      "uri": "urn:uuid:output_collection_Output_202108091550",
      "prov__wasDerivedFrom>": [
        {
          "_type": "Resource:prov__Entity:prov__Collection",
          "uri": "urn:uuid:input_collection_Model_202108091550"
        },
        {
          "_type": "Resource:prov__Entity:prov__Collection",
          "uri": "urn:uuid:input_collection_Radar_202108091550"
        },
        {
          "_type": "Resource:prov__Entity:prov__Collection",
          "uri": "urn:uuid:input_collection_IVS_202108091550"
        }
      ]
    }
  ]
}
@neo-technology-build-agent
Copy link
Collaborator Author

Comment by conker84
Thursday Nov 18, 2021 at 13:00 GMT


{
  "_type": "Resource:prov__Entity:provone__Data",
  "uri": "urn:uuid:output_adaguc_Zmax_202108091550.h5",
  "prov__hadMember": [
    {
      "_type": "Resource:prov__Entity:prov__Collection",
      "_direction": "OUT",
      "uri": "urn:uuid:output_collection_Output_202108091550"
...
    }
  ]
}

@neo-technology-build-agent
Copy link
Collaborator Author

Comment by mrveld94
Thursday Nov 18, 2021 at 13:05 GMT


Yes that would be perfect. Is this something that will be in the next version?
(Sorry used the wrong account earlier...)

@neo-technology-build-agent
Copy link
Collaborator Author

Comment by mrveld94
Wednesday Mar 30, 2022 at 07:07 GMT


Hi, is this something that is going to be implemented? And if so, when?

@gem-neo4j gem-neo4j added the enhancement New feature or request label Apr 6, 2023
@hvub
Copy link
Collaborator

hvub commented Nov 18, 2024

apoc.convert.toTree is deprecated according to https://neo4j.com/docs/apoc/current/overview/apoc.convert/apoc.convert.toTree/

The replacement is apoc.convert.toJsonTree, cf. https://neo4j.com/docs/apoc/current/overview/apoc.paths/apoc.paths.toJsonTree/

If the feature request is still relevant, please raise it for apoc.convert.toJsonTree.

Thanks.

@hvub hvub closed this as completed Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants