Nested list / SortOrder for Pattern Comprehension ListHow to return all newest nodes from neo4j?create relationships between nodes in parallelHow to nest a query with Neo4j?Nesting cypher queries with a collectionNeo4j Match / Retrieving Query taking too much time 25 secWhy does a neo4j query return things out of order and how do I put things in order?Neo4j modelling - sorting nodes ordered by distanceHow does one store group of nodes in neo4j?How do you output a path that includes relationship types?Neo4j Cypher pattern comprehension with optional match
Does the EU Common Fisheries Policy cover British Overseas Territories?
Reverse the word in a string with the same order in javascript
Any examples of headwear for races with animal ears?
Bayesian Nash Equilibria in Battle of Sexes
Lock in SQL Server and Oracle
Can fracking help reduce CO2?
TikZ how to make supply and demand arrows for nodes?
Can someone publish a story that happened to you?
How does a Swashbuckler rogue "fight with two weapons while safely darting away"?
What's the polite way to say "I need to urinate"?
Single Colour Mastermind Problem
Is it possible to measure lightning discharges as Nikola Tesla?
How to figure out whether the data is sample data or population data apart from the client's information?
Does jamais mean always or never in this context?
Find the coordinate of two line segments that are perpendicular
Why didn't this hurt this character as badly?
Why does processed meat contain preservatives, while canned fish needs not?
If Earth is tilted, why is Polaris always above the same spot?
Feels like I am getting dragged in office politics
Pressure to defend the relevance of one's area of mathematics
Is GOCE a satellite or aircraft?
Binary Numbers Magic Trick
How to set the font color of quantity objects (Version 11.3 vs version 12)?
You look catfish vs You look like a catfish
Nested list / SortOrder for Pattern Comprehension List
How to return all newest nodes from neo4j?create relationships between nodes in parallelHow to nest a query with Neo4j?Nesting cypher queries with a collectionNeo4j Match / Retrieving Query taking too much time 25 secWhy does a neo4j query return things out of order and how do I put things in order?Neo4j modelling - sorting nodes ordered by distanceHow does one store group of nodes in neo4j?How do you output a path that includes relationship types?Neo4j Cypher pattern comprehension with optional match
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Neo4j: What is proper syntax to nest and sort order List Comprehension Results?
My record has media nodes, each linked to users that altered the media. I am trying to gather all the information about my record.
Simple list comprehension works great:
MATCH r
RETURN r .*, Media: [(r)-[:HAS_MEDIA]->(m:Media)
Here are my questions:
1) if there are many media, how can I sort m list by .Order?
2) I also want to gather information about m, available through other nodes. So I tried nesting:
MATCH r
RETURN r .*, Media: [(r)-[:HAS_MEDIA]->(m:Media)
This throws a syntax error at the first nested bracket. Can it be done?
Ideally I'd like to collect more than u.UserID, including a t relationship property .DT.
3) When/if I get that working, same question as 1) - how can I sort u list by .DT?
Would be most grateful for any pointers!
--------- UPDATE After answer from cybersam:
YES! I need to add the new property names, as cybersam indicated. Thank you!
MATCH (r)
RETURN r .*, Media: [(r)-[:HAS_MEDIA]->(m:Media)
MATCH (r)
RETURN r m .URL, .Type, .Order, UserID: [(m)-[t:MODIFIED_BY]->(u) ]
I need to study the order call a bit more, but I do not believe ORDER BY r.Order at very end will work. I am returning just one r node. Within that r array I want sort the subkeys (so Media by .Order and User by t.DT).
neo4j cypher
add a comment |
Neo4j: What is proper syntax to nest and sort order List Comprehension Results?
My record has media nodes, each linked to users that altered the media. I am trying to gather all the information about my record.
Simple list comprehension works great:
MATCH r
RETURN r .*, Media: [(r)-[:HAS_MEDIA]->(m:Media)
Here are my questions:
1) if there are many media, how can I sort m list by .Order?
2) I also want to gather information about m, available through other nodes. So I tried nesting:
MATCH r
RETURN r .*, Media: [(r)-[:HAS_MEDIA]->(m:Media)
This throws a syntax error at the first nested bracket. Can it be done?
Ideally I'd like to collect more than u.UserID, including a t relationship property .DT.
3) When/if I get that working, same question as 1) - how can I sort u list by .DT?
Would be most grateful for any pointers!
--------- UPDATE After answer from cybersam:
YES! I need to add the new property names, as cybersam indicated. Thank you!
MATCH (r)
RETURN r .*, Media: [(r)-[:HAS_MEDIA]->(m:Media)
MATCH (r)
RETURN r m .URL, .Type, .Order, UserID: [(m)-[t:MODIFIED_BY]->(u) ]
I need to study the order call a bit more, but I do not believe ORDER BY r.Order at very end will work. I am returning just one r node. Within that r array I want sort the subkeys (so Media by .Order and User by t.DT).
neo4j cypher
add a comment |
Neo4j: What is proper syntax to nest and sort order List Comprehension Results?
My record has media nodes, each linked to users that altered the media. I am trying to gather all the information about my record.
Simple list comprehension works great:
MATCH r
RETURN r .*, Media: [(r)-[:HAS_MEDIA]->(m:Media)
Here are my questions:
1) if there are many media, how can I sort m list by .Order?
2) I also want to gather information about m, available through other nodes. So I tried nesting:
MATCH r
RETURN r .*, Media: [(r)-[:HAS_MEDIA]->(m:Media)
This throws a syntax error at the first nested bracket. Can it be done?
Ideally I'd like to collect more than u.UserID, including a t relationship property .DT.
3) When/if I get that working, same question as 1) - how can I sort u list by .DT?
Would be most grateful for any pointers!
--------- UPDATE After answer from cybersam:
YES! I need to add the new property names, as cybersam indicated. Thank you!
MATCH (r)
RETURN r .*, Media: [(r)-[:HAS_MEDIA]->(m:Media)
MATCH (r)
RETURN r m .URL, .Type, .Order, UserID: [(m)-[t:MODIFIED_BY]->(u) ]
I need to study the order call a bit more, but I do not believe ORDER BY r.Order at very end will work. I am returning just one r node. Within that r array I want sort the subkeys (so Media by .Order and User by t.DT).
neo4j cypher
Neo4j: What is proper syntax to nest and sort order List Comprehension Results?
My record has media nodes, each linked to users that altered the media. I am trying to gather all the information about my record.
Simple list comprehension works great:
MATCH r
RETURN r .*, Media: [(r)-[:HAS_MEDIA]->(m:Media)
Here are my questions:
1) if there are many media, how can I sort m list by .Order?
2) I also want to gather information about m, available through other nodes. So I tried nesting:
MATCH r
RETURN r .*, Media: [(r)-[:HAS_MEDIA]->(m:Media)
This throws a syntax error at the first nested bracket. Can it be done?
Ideally I'd like to collect more than u.UserID, including a t relationship property .DT.
3) When/if I get that working, same question as 1) - how can I sort u list by .DT?
Would be most grateful for any pointers!
--------- UPDATE After answer from cybersam:
YES! I need to add the new property names, as cybersam indicated. Thank you!
MATCH (r)
RETURN r .*, Media: [(r)-[:HAS_MEDIA]->(m:Media)
MATCH (r)
RETURN r m .URL, .Type, .Order, UserID: [(m)-[t:MODIFIED_BY]->(u) ]
I need to study the order call a bit more, but I do not believe ORDER BY r.Order at very end will work. I am returning just one r node. Within that r array I want sort the subkeys (so Media by .Order and User by t.DT).
neo4j cypher
neo4j cypher
edited Mar 22 at 22:57
cybersam
41.4k53354
41.4k53354
asked Mar 22 at 19:06
StephanieStephanie
63
63
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Does this work for you?
MATCH (r)
RETURN r
m u.UserID] ]
ORDER BY r.Order;
In a map projection, every property needs a name, so I used UserID
as the name of the inner pattern comprehension's result.
[UPDATED]
The query below may solve your updated question. The syntax for map projections and pattern comprehensions do not support sorting of contained lists.
MATCH (r)-[:HAS_MEDIA]->(m:Media)
WITH r, m ORDER BY m.Order
MATCH (m)-[t:MODIFIED_BY]->(u)
WITH r, m, u.UserID, DT: t.DT ORDER BY u.DT
WITH r, m.URL, .Type, .Order, User: COLLECT(u)
RETURN r .*, Media: COLLECT(m)
Thank you! I will respond in my original question because this field is limiting my response.
– Stephanie
Mar 22 at 21:41
See my updated answer.
– cybersam
Mar 22 at 22:57
Thanks for confirming that sorting contained list isn't supported yet for pattern comprehension. Given x different node labels to go through it gets extremely clunky to write out all the sequential queries for each one. For those that don't need a particular sort order for collection, I can sort my array after collecting it. Thank you for your help!
– Stephanie
Mar 23 at 18:02
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55306319%2fnested-list-sortorder-for-pattern-comprehension-list%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Does this work for you?
MATCH (r)
RETURN r
m u.UserID] ]
ORDER BY r.Order;
In a map projection, every property needs a name, so I used UserID
as the name of the inner pattern comprehension's result.
[UPDATED]
The query below may solve your updated question. The syntax for map projections and pattern comprehensions do not support sorting of contained lists.
MATCH (r)-[:HAS_MEDIA]->(m:Media)
WITH r, m ORDER BY m.Order
MATCH (m)-[t:MODIFIED_BY]->(u)
WITH r, m, u.UserID, DT: t.DT ORDER BY u.DT
WITH r, m.URL, .Type, .Order, User: COLLECT(u)
RETURN r .*, Media: COLLECT(m)
Thank you! I will respond in my original question because this field is limiting my response.
– Stephanie
Mar 22 at 21:41
See my updated answer.
– cybersam
Mar 22 at 22:57
Thanks for confirming that sorting contained list isn't supported yet for pattern comprehension. Given x different node labels to go through it gets extremely clunky to write out all the sequential queries for each one. For those that don't need a particular sort order for collection, I can sort my array after collecting it. Thank you for your help!
– Stephanie
Mar 23 at 18:02
add a comment |
Does this work for you?
MATCH (r)
RETURN r
m u.UserID] ]
ORDER BY r.Order;
In a map projection, every property needs a name, so I used UserID
as the name of the inner pattern comprehension's result.
[UPDATED]
The query below may solve your updated question. The syntax for map projections and pattern comprehensions do not support sorting of contained lists.
MATCH (r)-[:HAS_MEDIA]->(m:Media)
WITH r, m ORDER BY m.Order
MATCH (m)-[t:MODIFIED_BY]->(u)
WITH r, m, u.UserID, DT: t.DT ORDER BY u.DT
WITH r, m.URL, .Type, .Order, User: COLLECT(u)
RETURN r .*, Media: COLLECT(m)
Thank you! I will respond in my original question because this field is limiting my response.
– Stephanie
Mar 22 at 21:41
See my updated answer.
– cybersam
Mar 22 at 22:57
Thanks for confirming that sorting contained list isn't supported yet for pattern comprehension. Given x different node labels to go through it gets extremely clunky to write out all the sequential queries for each one. For those that don't need a particular sort order for collection, I can sort my array after collecting it. Thank you for your help!
– Stephanie
Mar 23 at 18:02
add a comment |
Does this work for you?
MATCH (r)
RETURN r
m u.UserID] ]
ORDER BY r.Order;
In a map projection, every property needs a name, so I used UserID
as the name of the inner pattern comprehension's result.
[UPDATED]
The query below may solve your updated question. The syntax for map projections and pattern comprehensions do not support sorting of contained lists.
MATCH (r)-[:HAS_MEDIA]->(m:Media)
WITH r, m ORDER BY m.Order
MATCH (m)-[t:MODIFIED_BY]->(u)
WITH r, m, u.UserID, DT: t.DT ORDER BY u.DT
WITH r, m.URL, .Type, .Order, User: COLLECT(u)
RETURN r .*, Media: COLLECT(m)
Does this work for you?
MATCH (r)
RETURN r
m u.UserID] ]
ORDER BY r.Order;
In a map projection, every property needs a name, so I used UserID
as the name of the inner pattern comprehension's result.
[UPDATED]
The query below may solve your updated question. The syntax for map projections and pattern comprehensions do not support sorting of contained lists.
MATCH (r)-[:HAS_MEDIA]->(m:Media)
WITH r, m ORDER BY m.Order
MATCH (m)-[t:MODIFIED_BY]->(u)
WITH r, m, u.UserID, DT: t.DT ORDER BY u.DT
WITH r, m.URL, .Type, .Order, User: COLLECT(u)
RETURN r .*, Media: COLLECT(m)
edited Mar 22 at 22:57
answered Mar 22 at 19:20
cybersamcybersam
41.4k53354
41.4k53354
Thank you! I will respond in my original question because this field is limiting my response.
– Stephanie
Mar 22 at 21:41
See my updated answer.
– cybersam
Mar 22 at 22:57
Thanks for confirming that sorting contained list isn't supported yet for pattern comprehension. Given x different node labels to go through it gets extremely clunky to write out all the sequential queries for each one. For those that don't need a particular sort order for collection, I can sort my array after collecting it. Thank you for your help!
– Stephanie
Mar 23 at 18:02
add a comment |
Thank you! I will respond in my original question because this field is limiting my response.
– Stephanie
Mar 22 at 21:41
See my updated answer.
– cybersam
Mar 22 at 22:57
Thanks for confirming that sorting contained list isn't supported yet for pattern comprehension. Given x different node labels to go through it gets extremely clunky to write out all the sequential queries for each one. For those that don't need a particular sort order for collection, I can sort my array after collecting it. Thank you for your help!
– Stephanie
Mar 23 at 18:02
Thank you! I will respond in my original question because this field is limiting my response.
– Stephanie
Mar 22 at 21:41
Thank you! I will respond in my original question because this field is limiting my response.
– Stephanie
Mar 22 at 21:41
See my updated answer.
– cybersam
Mar 22 at 22:57
See my updated answer.
– cybersam
Mar 22 at 22:57
Thanks for confirming that sorting contained list isn't supported yet for pattern comprehension. Given x different node labels to go through it gets extremely clunky to write out all the sequential queries for each one. For those that don't need a particular sort order for collection, I can sort my array after collecting it. Thank you for your help!
– Stephanie
Mar 23 at 18:02
Thanks for confirming that sorting contained list isn't supported yet for pattern comprehension. Given x different node labels to go through it gets extremely clunky to write out all the sequential queries for each one. For those that don't need a particular sort order for collection, I can sort my array after collecting it. Thank you for your help!
– Stephanie
Mar 23 at 18:02
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55306319%2fnested-list-sortorder-for-pattern-comprehension-list%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown