cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to get the individual values from given below query

Hi Team,
I am trying to run the procedure in java through bolt statement.like below

StatementResult result1 = session.run("MATCH (n) WHERE ID(n)=125 CALL apoc.path.expandConfig(n,{relationshipFilter: '',minLevel:1, maxLevel: 20,labelFilter:'-Dense|-Product1|-ProductType1', maxLevel:4}) YIELD path RETURN path limit 8”);

From this I am getting result in java after running is:

{
"path":{
"nodes":[
{
"labels":[
"SelName"
],
"id":125,
"properties":{
"selName":{
"val":"EMB"
},
"norm_name":{
"val":"emb"
},
"platfm":{
"val":"amazon.in"
}
}
}
],
"relationships":[

  ],
  "segments":[  

  ]

}
}

But I want output like below I do not want to print path, nodes,labels,properties etc.But I want simply like below in java:

[{"selName":"EMB","norm_name":"emb","platfm":"│
│amazon.in"},{},{}]

Please help me out to get the output

9 REPLIES 9

Looks like you only want the properties of nodes in the path? If so, try:

RETURN [node in nodes(path) | properties(node)] as nodes
LIMIT 8

Thank you Andrew for responding,
After running ur given format I am getting the data with nodes but I want now print with only selName can you suggest with same query.
Below is json format current I am getting,

{"nodes":[{"selName":"EMB","norm_name":"emb","platfm":"amazon.in"},{"selName":"emb1","norm_name":"emb","platfm":"ebay.com"},{"sellerName":"emb2","norm_name":"emb","platfm":"eBay.com"}],
[{"selName":"EMB11","norm_name":"emb11","platfm":"amazon.in"},{"selName":"emb111","norm_name":"emb","platfrm":"ebay.com"},{"sellerName":"emb222","norm_name":"emb","platfrm":"eBay.com"}]}

Below is query,
MATCH (n) WHERE ID(n)=125 CALL apoc.path.expandConfig(n,{relationshipFilter: '',minLevel:1, maxLevel: 20,labelFilter:'-Dense|-Product|-ProductType', maxLevel:4}) YIELD path RETURN [node in nodes(path) | properties(node)] as nodes LIMIT 8

If you only need a certain property, then specify that in the list projection. Looks like you have differing property keys depending on certain nodes, so we can use coalesce() to find the first non-null value:

MATCH (n) WHERE ID(n)=125 
CALL apoc.path.expandConfig(n,{relationshipFilter: '',minLevel:1, maxLevel: 20,labelFilter:'-Dense|-Product|-ProductType', maxLevel:4}) YIELD path 
RETURN [node in nodes(path) | coalesce(node.selName, node.sellerName)] as nodes 
LIMIT 8

Hi Andrew, while running above query I am getting below issue,

Here is issue,
Neo.ClientError.Statement.SyntaxError: Invalid input '|': expected whitespace, comment, '.', node labels, '[', "=~", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', "<>", "!=", '<', '>', "<=", ">=", AND, XOR, OR or ']' (line 1, column 225 (offset: 224))
"MATCH (n) WHERE ID(n)=125 CALL apoc.path.expandConfig(n,{relationshipFilter: '',minLevel:1, maxLevel: 20,labelFilter:'-Dense|-Product|-ProductType', maxLevel:4}) YIELD path RETURN [node in nodes(path) | properties(node) | COLLECT(node.selName, node.sellerName)] as nodes LIMIT 8"
^

Can you please suggest..

The query you ran is not the query I provided. You have an extra segment in the list projection that wasn't there before, and you're using COLLECT() instead of COALESCE() (which won't work in this case). Is there some reason the query I provided isn't working for you?

Sorry for wrong sent Andrew,
I am using below query itself which is given by you , here is

MATCH (n) WHERE ID(n)=125 CALL apoc.path.expandConfig(n,{relationshipFilter: '',minLevel:1, maxLevel: 20,labelFilter:'-Dense|-Product|-ProductType', maxLevel:4}) YIELD path RETURN [node in nodes(path) | coalesce(node.selName, node.sellerName)] as nodes LIMIT 8

But same issue getting above mentioned..

Actually the query looks good, it's working for me. What version of Neo4j are you using?

yes its working fine Andrew there is a small mistake done by me i.e.,I written return twice...
Thanks again..

Do we have any solution for,
How to do expand and collapse PARENT AND child nodes in NeoVis by clicking on Nodes.
I am getting result with full nodes information but I want expand and collapse nodes for same results.
Please reply me as soon.

Here is I am following NeoVis POC Link Below


Thanks....

That's a completely different question unrelated to this one. I think you had best create a separate question for it in the appropriate category. I haven't worked with Neovis myself here, others may be able to help.