rayman
rayman

Reputation: 21606

How to do arbitrate operation(minus) using cypher

I am trying to delete all relationships which existed more than 2 hours in the system.

I am adding property timestamp each time I create relationship.

I am trying to create a schedule process which deleting all relationship which their created date is longer than 2 hours.

So I am looking for something like this:

*assume reportDate is timestamp in mili's *7200000 - 2 hours in milli's

match (p1:C9)-[r:follow]->(p2:C9) 
where (r.reportDate - 1447073161751) > 7200000
delete r

It didnt work. error from Cypher:

Don't know how to Subtract(r.reportDate,{  AUTOINT0}) `1447073161751` with `1447090476190`

how i should adjust my where clauses to match my requirement ?

Thanks, ray.

Upvotes: 2

Views: 633

Answers (1)

MicTech
MicTech

Reputation: 45033

How values at reportDate looks like?
What is represented by 1447073161751?
What is datatype of reportDate?

  • If it's string you need to convert to int by TOINT()

Try select node first:

MATCH (p1:C9)-[r:follow]->(p2:C9) 
WHERE (r.reportDate - 1447073161751) > 7200000 
RETURN p1, r, p2

That Cypher works for me without any problem.

Here is the example, which I tried:

Version with string datatype

Create

CREATE (p1:C9)-[r:follow {reportDate: "123"}]->(p2:C9)

Delete

MATCH (p1:C9)-[r:follow]->(p2:C9) 
WHERE (TOINT(r.reportDate) - 100) > 20 
DELETE r

Check

MATCH (p1:C9)-[r:follow]->(p2:C9) 
WHERE (TOINT(r.reportDate) - 100) > 20 
RETURN r

Version with integer datatype

Create

CREATE (p1:C9)-[r:follow {reportDate: 123}]->(p2:C9)

Delete

MATCH (p1:C9)-[r:follow]->(p2:C9) 
WHERE (r.reportDate - 100) > 20 
DELETE r

Check

MATCH (p1:C9)-[r:follow]->(p2:C9) 
WHERE (r.reportDate - 100) > 20 
RETURN r

Upvotes: 1

Related Questions