Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-27-2018 11:59 AM
Hi Everyone ,
I need some help from you guys.
i know that we can return json output from cypher queries.but my scenario is quite different
i have nodes in below format
DNA<------EXP<------HAR<-------PI
now problm is that this path can have multiple EXP and Multiple HAR
i want to create json like this
PI{
PI Node Details,
HAR{
HARVEST Node details,
Exp{
Expression node detail,
Dna{
Dna Node details
}
}
}
}
please help me to handle dynamic Exp and Har.
Thanks in advance
10-27-2018 05:59 PM
Can you see if apoc.convert.toTree
helps:
match path = (a)- ->(b) with collect(path) as paths
call apoc.convert.toTree(paths) yield value
return value
10-29-2018 01:13 AM
Thanks michael.
It is working for me ..
but now problem is i want to get some particular properties in this path like we have some BARCODE in each node that comes in this path .i want to get these barcodes only in json not all properties.
please help me in this
10-30-2018 12:46 AM
Hi Michael ,
i want some json that have data from another node as well
please find query below that return all the nodes and info i need to display in json .
MATCH (a:ENTITY)<-[:Having]-(:ENTITY_TYPE{ENTITY_TYPE_NAME:'x'})
MATCH (b:ENTITY)<-[:Having]-(:ENTITY_TYPE{ENTITY_TYPE_NAME:'y'})
match path = (a)-[*]->(c:z{BARCODE:'asdf'})-[*]->(b)
// get all nodes (departments) from path
with nodes(path) as deps
// unwind deps collection to individual departments
unwind deps as dep
// match workers and managers directly connected to dep nodes
Optional match (dep)-[:ASSOCIATED{PREDICATE:'abc'}]->(u:ENTITY)
with collect(dep) as d, collect(u) as u
with collect(d + u) as p
call apoc.convert.toTree(p) yield value return value
in above i have a query with optional match, i want to show u's barcode as json attribute for the path
please help me in this i am getting error in above query
Type mismatch: expected List<Path> but was List<List<Node>>
11-07-2018 12:16 AM
There are some apoc functions to create paths from nodes + rels.
You will be able to see their signature in call apoc.help("apoc.path")
Also there are apoc functions for creating JSON from custom documents (nested maps/lists).
esp. apoc.convert.toJson
Those should help you with what you want to do.
11-11-2018 11:16 PM
Hi michael,
Thanks for all your help.
my query regarding data lineage.
my data is in following tree structure.
A <-associated- B <-associated- C <-associated- D <-associated- E
D <-associated- F
D <-associated- G
C <-associated- K
C <-associated- L
I want to show this data in a nested json
i will give only one node info according to that info i want to get json from Top most to lower most node and it should contain all nested data and subgraph
Thank you in advance
11-21-2018 02:45 AM
Can you try with the things I mentioned and let us know if you ran into any concrete questions.
11-21-2018 02:53 AM
Hi @michael.hunger,
Thank you for all your help.
i used some different approch with your inputs and i got the desired output as i want.
i tried with your inputs but it was not giving the output as i want.
Could you please look into below question for import.it would be very helpful for me .
https://community.neo4j.com/t/load-data-from-impala-to-neo4j/3093/11
Thank you
01-02-2019 02:14 AM
Hi, is it possible to get only tree structure (only id-s, or some certain selected-values from children) ?
apoc.convert.toTree returns with the structure also all properties of the child nodes in the tree.
01-02-2019 04:24 AM
Hey @paul.are
you can do this using java code and JSON parser.
i did the same since i need only selected property from the json.
01-02-2019 04:38 AM
Thank you for reply. I was hoping there is a method to reduce the ammount of data transmitted to application on database side. As i understand, you suggest to transform responce from database to suitable format on application level - in my case it means transmitting lots of information that is not needed by application.
01-09-2019 01:59 PM
good idea can you create an APOC issue, we can add it as a config option to include/exclude certain properties
01-10-2019 05:51 AM
Thanks for suggestion. Created issue:
12-10-2018 08:51 AM
Great thread. I'm working with Neo4j embedded and I'm looking for an example of call the equivalent of "apoc.convert.toJson(path)" from Java directly (not from Cypher). I have include the Maven dependency below but I can't figure out the syntax.
<dependency>
<groupId>org.neo4j.procedure</groupId>
<artifactId>apoc</artifactId>
<version>3.5.0.1</version>
</dependency>
I've tried the following but it returns an infinite recursion:
apoc.convert.Json converter = new apoc.convert.Json();
response = converter.toJson(p.path);
Thanks in advance
All the sessions of the conference are now available online