logo
down
shadow

Neo4j cypher query collect in collect


Neo4j cypher query collect in collect

By : Sune Adler Miltersen
Date : November 19 2020, 01:01 AM
I think the issue was by ths following , I have provided a Neo4j Gist that illustrates a solution. In short it uses literal maps to format the data and two collects to make sure that the brands does not occur multiple times.
code :
MATCH 
    (brand:Brand)-[:CREATED_A]->(campaign:Campaign)<-->(node)
WITH 
    brand, 
    { 
        campaign : campaign, 
        nodes : COLLECT(node)
    } AS campaigns
WITH 
    { 
        brand : brand, 
        campaigns : COLLECT(campaigns)
    } AS brands
RETURN brands


Share : facebook icon twitter icon
Neo4j cypher query : using ORDER BY with COLLECT(S)

Neo4j cypher query : using ORDER BY with COLLECT(S)


By : chips
Date : March 29 2020, 07:55 AM
Hope that helps The "Order by" expects a property on a node or a relationship. The "questions" in your query is a collection of nodes instead of a node/relationship, you can't sort a collection using "Order by", you can only sort nodes or relationships on their properties.
In order to use "Order by", you need to return the questions as a column of rows rather than a collection. In terms of the relationships indicated in your original query, the following query should return the general and the specific game questions as a column of rows and sort them on the property "dateCreated",
code :
START group = node(627) 
Match question-[?:GENERAL_QUESTION|GAME_QUESTION]->()<-[:GAMES*0..1]-(group)
Return distinct question
Order by question.dateCreated
START group = node(627) 
Match question-[:GENERAL_QUESTION|GAME_QUESTION]->()-[*0..4]-(group)
Return distinct question
Order by question.dateCreated
START group = node(627) 
MATCH question-[*]-group
Where question-[:GENERAL_QUESTION]->group or (question-[:GAME_QUESTION]->()<-[:QUESTIONS]-()-[:INTERESTS]->()<-[:HAS_INTERESTS_FOR]-()<-[:INTERESTS]-group)
Return distinct q
Order by q.dateCreated
Neo4j Cypher query - collect elements from 2 different variables to single list

Neo4j Cypher query - collect elements from 2 different variables to single list


By : Nicholas M
Date : March 29 2020, 07:55 AM
Hope this helps I have a following part of Cypher query: , You can try something like this with apoc:
code :
MATCH (chparent:Characteristic {characteristicId: <someid>})
OPTIONAL MATCH (chparent)-[:CONTAINS]->(chchild:Characteristic)
WITH apoc.coll.union(chparent,chchild) as distinctList
...
MATCH (chparent:Characteristic {characteristicId: <someid>})
OPTIONAL MATCH (chparent)-[:CONTAINS]->(chchild:Characteristic)
WITH chparent,collect(distinct(chchild)) as childs
WITH chparent + childs as list
....
Neo4j - Difference between Cypher query in Browser vs with Driver? (WITH COLLECT, apoc, etc)

Neo4j - Difference between Cypher query in Browser vs with Driver? (WITH COLLECT, apoc, etc)


By : user6881331
Date : March 29 2020, 07:55 AM
I wish this help you You should add whitespace (like a space or newline) between clauses, otherwise the query string is not always parsed the way you intended.
Try this (notice the extra space at the ends of the first 4 strings):
code :
const result = this.session.run(
  'MATCH p=(n:Category)-[:subcategory*]->(m) ' +
  'WHERE NOT (m)-[:subcategory]->() ' +
  'WITH COLLECT(p) as ps ' +
  'CALL apoc.convert.toTree(ps) yield value ' +
  'RETURN value;'
);
MATCH p=(n:Category)-[:subcategory*]->(m)WHERE NOT (m)-[:subcategory]->()WITH COLLECT(p) as psCALL apoc.convert.toTree(ps) yield valueRETURN value;
Neo4j cypher complicated query sort ,count, sum before collect

Neo4j cypher complicated query sort ,count, sum before collect


By : alex.chih
Date : March 29 2020, 07:55 AM
hope this fix your issue I am newbie with neo4j db and just started learning it, looking for some help, because I am stuck. Is it possible to get it in one cypher query? how? , Ok, that was fast :D I finally got it!
Neo4j cypher query order by with collect

Neo4j cypher query order by with collect


By : han
Date : March 29 2020, 07:55 AM
With these it helps You simply need to order the user nodes by the attribute of your choice prior to collecting them. Something like this..,
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org