Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.4k views
in Technique[技术] by (71.8m points)

neo4j - LIMIT not working inside apoc procedure apoc.cypher.run

I am trying to run following Neo4j cypher Query:

MATCH (m:Person { id: '$id'})-[:FOLLOWS]->(f:Person) 
CALL apoc.cypher.run('WITH {f} as f 
MATCH (f)-[:HAS_ACTIVITY]->(la:Activity)-[:NEXT*0..]->(act:Activity)
RETURN act LIMIT 10', {f:f}) YIELD value
WITH value.act as act, f 
MATCH (act:Activity)-[:HAS_OBJECT]->(obj:MediaItem) WHERE NOT(obj.readPermission='PUBLIC')
OPTIONAL MATCH (act)-[:HAS_TARGET]->(t:Person) with act,f,obj,t 
WHERE t is null or not labels(t) in ['Group'] with act.aggregationId as agg, 
act.aggregationType as aggType,collect({ activity : act, object : obj, target : t}) as
aggregationActivity,collect(act) as aggregationActivity1,collect(distinct f) as friendlist 
WITH agg,aggType,aggregationActivity,friendlist,head(aggregationActivity1) as 
a1 OPTIONAL MATCH (ow:Person {id:a1.ownerId}) 
RETURN agg,ow,friendlist, a1.published as x, aggregationActivity

In the above query, I am trying to filter out first 10 activities inside APOC procedure(ref: https://neo4j.com/developer/kb/limiting-match-results-per-row/) so that the remaining execution happens on the relevant results. But the value yielded from APOC procedure is having more than 10 results. How can I get LIMIT working inside my APOC procedure. Neo4j Version: 3.0.6 APOC Procedure version: 3.0.8.6

Please find attached PROFILE and EXPLAIN screenshot: PROFILE EXPLAIN


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...