Created
May 28, 2014 05:07
-
-
Save bunkat/0d079983718cdd881168 to your computer and use it in GitHub Desktop.
Neo4j Query and Profile Output for querying files with optional matches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ColumnFilter(symKeys=["f", "r"], returnItemNames=["r"], _rows=2, _db_hits=0) | |
Extract(symKeys=["f", "r"], exprKeys=["r"], _rows=2, _db_hits=20) | |
ColumnFilter(symKeys=["f", "xs", "r"], returnItemNames=["f", "r"], _rows=2, _db_hits=0) | |
Extract(symKeys=["f", "xs", "r"], exprKeys=["r"], _rows=2, _db_hits=0) | |
ColumnFilter(symKeys=["f", "r", " INTERNAL_AGGREGATEd2d4a2d9-40fe-4813-be68-60e8e99c6e05"], returnItemNames=["f", "xs", "r"], _rows=2, _db_hits=0) | |
EagerAggregation(keys=["f", "r"], aggregates=["( INTERNAL_AGGREGATEd2d4a2d9-40fe-4813-be68-60e8e99c6e05,Collect(x))"], _rows=2, _db_hits=0) | |
NullableMatch(_rows=2, _db_hits=0) | |
SimplePatternMatcher(g="(f)-[' UNNAMED1483']-(x)", _rows=0, _db_hits=0) | |
ColumnFilter(symKeys=["f", "xs", "r"], returnItemNames=["f", "r"], _rows=2, _db_hits=0) | |
Extract(symKeys=["f", "xs", "r"], exprKeys=["r"], _rows=2, _db_hits=2) | |
ColumnFilter(symKeys=["f", "r", " INTERNAL_AGGREGATEd3ef1494-6f4c-45ca-8ebf-62731ea1dfb9"], returnItemNames=["f", "xs", "r"], _rows=2, _db_hits=0) | |
EagerAggregation(keys=["f", "r"], aggregates=["( INTERNAL_AGGREGATEd3ef1494-6f4c-45ca-8ebf-62731ea1dfb9,Collect(x))"], _rows=2, _db_hits=0) | |
NullableMatch(_rows=2, _db_hits=0) | |
Filter(pred="NOT(hasLabel(x:group(10)))", _rows=1, _db_hits=0) | |
SimplePatternMatcher(g="(x)-[' UNNAMED1157']-(f)", _rows=1, _db_hits=0) | |
ColumnFilter(symKeys=[" UNNAMED899", "f", "ha", " UNNAMED873", "r", "hc"], returnItemNames=["f", "r"], _rows=2, _db_hits=0) | |
Extract(symKeys=[" UNNAMED899", "f", "ha", " UNNAMED873", "r", "hc"], exprKeys=["r"], _rows=2, _db_hits=6) | |
NullableMatch(_rows=2, _db_hits=2) | |
Filter(pred="((hasLabel(ha:activity(11)) AND hasLabel(hc:contact(2))) AND hasLabel(ha:activity(11)))", _rows=1, _db_hits=0) | |
PatternMatcher(g="(hc)-[' UNNAMED899']-(ha),(f)-[' UNNAMED873']-(ha)", _rows=1, _db_hits=1) | |
ColumnFilter(symKeys=["f", "ca", " UNNAMED637", "cc", "r", " UNNAMED663"], returnItemNames=["f", "r"], _rows=2, _db_hits=0) | |
Extract(symKeys=["f", "ca", " UNNAMED637", "cc", "r", " UNNAMED663"], exprKeys=["r"], _rows=2, _db_hits=6) | |
NullableMatch(_rows=2, _db_hits=2) | |
Filter(pred="((hasLabel(ca:activity(11)) AND hasLabel(cc:contact(2))) AND hasLabel(ca:activity(11)))", _rows=1, _db_hits=0) | |
PatternMatcher(g="(f)-[' UNNAMED637']-(ca),(cc)-[' UNNAMED663']-(ca)", _rows=1, _db_hits=1) | |
ColumnFilter(symKeys=[" UNNAMED204", " UNNAMED258", "f", " UNNAMED269", "xp", " UNNAMED225", " UNNAMED276", "c", "r"], returnItemNames=["f", "r"], _rows=2, _db_hits=0) | |
Extract(symKeys=[" UNNAMED204", " UNNAMED258", "f", " UNNAMED269", "xp", " UNNAMED225", " UNNAMED276", "c", "r"], exprKeys=["r"], _rows=2, _db_hits=4) | |
Filter(pred="(((((((((any(-_-INNER-_- in Collection(List(Literal(Owners), Literal(Admins), Literal(Project Admins), Literal(Project Clients))) where Property(r,name(0)) == -_-INNER-_-) OR nonEmpty(PathExpression((f)-[ UNNAMED386:CONTACT]->(c), true))) OR nonEmpty(PathExpression((f)-[ UNNAMED413:CREATED]->(427:activity(11)), UNNAMED437=(c)-[USERACTIVITY*0..4]->(427:activity(11)), true))) OR nonEmpty(PathExpression((485:material(23))-[ UNNAMED474:FILE]->(f),(485:material(23))-[ UNNAMED495:CONTACT]->(c), true))) OR nonEmpty(PathExpression((533:task(22))-[ UNNAMED522:FILE]->(f),(533:task(22))-[ UNNAMED539:CONTACT]->(c), true))) AND hasLabel(r:role(4))) AND hasLabel(r:role(4))) AND hasLabel( UNNAMED269:files(35))) AND hasLabel( UNNAMED269:files(35))) AND hasLabel(f:file(24)))", _rows=2, _db_hits=7222) | |
PatternMatcher(g="( UNNAMED269)-[' UNNAMED276']-(f),(xp)-[' UNNAMED258']-( UNNAMED269),(r)-[' UNNAMED225']-(xp),(c)-[' UNNAMED204']-(r)", _rows=2, _db_hits=7317) | |
ColumnFilter(symKeys=["u", " UNNAMED108", "xp", "p", "c", " UNNAMED141"], returnItemNames=["c", "xp"], _rows=1, _db_hits=0) | |
Filter(pred="hasLabel(xp:project(21))", _rows=1, _db_hits=0) | |
PatternMatcher(g="(p)-[' UNNAMED141']-(xp)", _rows=1, _db_hits=0) | |
Filter(pred="hasLabel(c:contact(2))", _rows=1, _db_hits=0) | |
SimplePatternMatcher(g="(u)-[' UNNAMED108']-(c)", _rows=1, _db_hits=0) | |
SchemaIndex(identifier="p", _db_hits=0, _rows=1, label="project", query="Literal(ls9y6m0Hrclsx)", identifiers=["p"], property="id", producer="SchemaIndex") | |
SchemaIndex(identifier="u", _db_hits=0, _rows=1, label="user", query="Literal(ls9fyQwgM0dnZ)", identifiers=["u"], property="id", producer="SchemaIndex") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MATCH | |
(u:user { id: "ls9fyQwgM0dnZ" }), (p:project { id: "ls9y6m0Hrclsx" }) | |
WITH u, p | |
MATCH | |
(u)-[:CONTACT]->(c:contact), | |
(p)-[:SUBPROJECT*0..5]->(xp:project) | |
WITH c, xp | |
MATCH | |
(c)-[:CONTACT]->(r:role)-[:CONTACT*1..10]->(xp), | |
(xp)-[:FILE]->(:files)-[:FILE]->(f:file) | |
WHERE | |
r.name IN ["Owners", "Admins", "Project Admins", "Project Clients"] | |
OR (f)-[:CONTACT]->(c) | |
OR (f)-[:CREATED]->(:activity)<-[:USERACTIVITY*0..4]-(c) | |
OR (f)<-[:FILE]-(:material)-[:CONTACT]->(c) | |
OR (f)<-[:FILE]-(:task)-[:CONTACT]->(c) | |
WITH f, {accessedrole: r.name, accessedby: c.id} AS r | |
OPTIONAL MATCH | |
(f)-[:CREATED]->(ca:activity)<-[:USERACTIVITY*1..4]-(cc:contact) | |
WITH f, { | |
accessedrole: r.accessedrole, accessedby: r.accessedby, | |
createdat: ca.createdat, createdby: {id: cc.id, object: cc.object}} AS r | |
OPTIONAL MATCH | |
(f)-[:HISTORY]->(ha:activity)<-[:USERACTIVITY*1..4]-(hc:contact) | |
WITH f, { | |
accessedrole: r.accessedrole, accessedby: r.accessedby, | |
createdat: r.createdat, createdby: r.createdby, | |
updatedat: ha.createdat, updatedby: {id: hc.id, object: hc.object}} AS r | |
OPTIONAL MATCH (f)<-[:FILE]-(x) WHERE NOT (x:group) | |
WITH f, COLLECT(x) AS xs, r | |
WITH f, { | |
accessedrole: r.accessedrole, accessedby: r.accessedby, | |
createdat: r.createdat, createdby: r.createdby, | |
updatedat: r.createdat, updatedby: r.updatedby, | |
related: [x IN xs | {id: x.id, object: x.object}] | |
} AS r | |
OPTIONAL MATCH (f)-[:TAG]->(x) | |
WITH f, COLLECT(x) AS xs, r | |
WITH f, { | |
accessedrole: r.accessedrole, accessedby: r.accessedby, | |
createdat: r.createdat, createdby: r.createdby, | |
updatedat: r.createdat, updatedby: r.updatedby, | |
related: r.related, | |
tags: [x IN xs | {id: x.id, object: x.object, name: x.name}] | |
} AS r | |
RETURN { | |
id: f.id, object: f.object, projectid: f.projectid, | |
no: f.no, name: f.name, description: f.description, url: f.url, | |
mime: f.mime, thumbnail: f.thumbnail, size: f.size, | |
accessedrole: r.accessedrole, accessedby: r.accessedby, | |
createdat: r.createdat, createdby: r.createdby, | |
updatedat: r.createdat, updatedby: r.updatedby, | |
related: r.related, tags: r.tags | |
} AS r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment