0

I meet a problem with count request of neo4j with nodejs.

Here my problem : When I insert a data, it will present like this:

start a = node(0)

create unique a-[:HAS_ID]->(b{id:'xx'})

create unique b-[:HAS_INFO]->(c{info:'xx'})

return a,b,c;

because it's unique node, so that it will not insert a new node if there are a same node exist. But, I wanna count how many request to call this query. Ex :

   request: -domain/id01/info

     --return a node[0], b node[1] and c node[2]

add another data:

     request: -domain/id02/info
      -- return : a node[0], b node[3], c node[4]

call it again :

     request: -domain/id01/info

     --return a node[0], b node[1] and c node[2] //but here is any attribute or properties count to 2.

I've read any solution about strength. It told me create an properties of relationship as example :

     [:HAS_INFO{strength:num}]

and let it increase but I still don't get it. Anyone please give me solution and tell me how to do it. Thank you.

more info : Representing (and incrementing) relationship strength in Neo4j

Community
  • 1
  • 1
Kai
  • 3,104
  • 2
  • 19
  • 30

1 Answers1

1

You can use the CASE statement, see http://gist.neo4j.org/?6052414 for an example. Feel free to for the underlying gist and improve it!

MATCH path=(a)-[rel:HAS_INFO]->(b)
WHERE a.name?='A' AND b.name?='Info'
SET rel.weight = (
  CASE
   WHEN not(has(rel.weight))
   THEN 0
   ELSE rel.weight + 1
  END)
RETURN path, rel.weight;
Peter Neubauer
  • 6,311
  • 1
  • 21
  • 24