🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 102 (from laksa003)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

📄
INDEXABLE
✅
CRAWLED
7 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.3 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://dzone.com/articles/neo4j-collecting-multiple
Last Crawled2026-04-02 13:05:25 (7 days ago)
First Indexed2015-09-29 17:46:12 (10 years ago)
HTTP Status Code200
Meta TitleNeo4j: COLLECTing Multiple Values (Too Many Parameters for Function ‘Collect’)
Meta DescriptionOne of my favourite functions in Neo4j’s cypher query language is COLLECT which allows us to group items into an array for later consumption. However, I’ve...
Meta Canonicalnull
Boilerpipe Text
Likes (0) Save 10.2K Views Join the DZone community and get the full member experience. Join For Free One of my favourite functions in Neo4j’s cypher query language is COLLECT which allows us to group items into an array for later consumption. However, I’ve noticed that people sometimes have trouble working out how to collect multiple items with COLLECT and struggle to find a way to do so. Consider the following data set: create (p:Person {name: "Mark"}) create (e1:Event {name: "Event1", timestamp: 1234}) create (e2:Event {name: "Event2", timestamp: 4567})   create (p)-[:EVENT]->(e1) create (p)-[:EVENT]->(e2) If we wanted to return each person along with a collection of the event names they’d participated in we could write the following: $ MATCH (p:Person)-[:EVENT]->(e) > RETURN p, COLLECT(e.name); +--------------------------------------------+ | p | COLLECT(e.name) | +--------------------------------------------+ | Node[0]{name:"Mark"} | ["Event1","Event2"] | +--------------------------------------------+ 1 row That works nicely, but what about if we want to collect the event name and the timestamp but don’t want to return the entire event node? An approach I’ve seen a few people try during workshops is the following: MATCH (p:Person)-[:EVENT]->(e) RETURN p, COLLECT(e.name, e.timestamp) Unfortunately this doesn’t compile: SyntaxException: Too many parameters for function 'collect' (line 2, column 11) "RETURN p, COLLECT(e.name, e.timestamp)" ^ As the error message suggests, the COLLECT function only takes one argument so we need to find another way to solve our problem. One way is to put the two values into a literal array which will result in an array of arrays as our return result: $ MATCH (p:Person)-[:EVENT]->(e) > RETURN p, COLLECT([e.name, e.timestamp]); +----------------------------------------------------------+ | p | COLLECT([e.name, e.timestamp]) | +----------------------------------------------------------+ | Node[0]{name:"Mark"} | [["Event1",1234],["Event2",4567]] | +----------------------------------------------------------+ 1 row The annoying thing about this approach is that as you add more items you’ll forget in which position you’ve put each bit of data so I think a preferable approach is to collect a map of items instead: $ MATCH (p:Person)-[:EVENT]->(e) > RETURN p, COLLECT({eventName: e.name, eventTimestamp: e.timestamp}); +--------------------------------------------------------------------------------------------------------------------------+ | p | COLLECT({eventName: e.name, eventTimestamp: e.timestamp}) | +--------------------------------------------------------------------------------------------------------------------------+ | Node[0]{name:"Mark"} | [{eventName -> "Event1", eventTimestamp -> 1234},{eventName -> "Event2", eventTimestamp -> 4567}] | +--------------------------------------------------------------------------------------------------------------------------+ 1 row During the Clojure Neo4j Hackathon that we ran earlier this week this proved to be a particularly pleasing approach as we could easily destructure the collection of maps in our Clojure code. Neo4j
Markdown
[![DZone](https://dz2cdn1.dzone.com/themes/dz20/images/dz_logo_2021_cropped.png)](https://dzone.com/) Thanks for visiting DZone today, ![user avatar]() [Edit Profile](https://dzone.com/articles/neo4j-collecting-multiple) - [Manage Email Subscriptions](https://dzone.com/articles/neo4j-collecting-multiple) - [How to Post to DZone](https://dzone.com/articles/how-to-submit-a-post-to-dzone?utm_source=DZone&utm_medium=user_dropdown&utm_campaign=how_to_post) - [Article Submission Guidelines](https://dzone.com/articles/dzones-article-submission-guidelines) [Sign Out](https://dzone.com/users/logout.html) [View Profile](https://dzone.com/articles/neo4j-collecting-multiple) Post - ![](https://dz2cdn1.dzone.com/themes/dz20/images/dz-postarticle.svg) [Post an Article](https://dzone.com/content/article/post.html) - [Manage My Drafts](https://dzone.com/articles/neo4j-collecting-multiple) Over 2 million developers have joined DZone. [Log In](https://dzone.com/users/login.html) / [Join](https://dzone.com/static/registration.html) [Refcards](https://dzone.com/refcardz) [Trend Reports](https://dzone.com/trendreports) [Events](https://dzone.com/events) [Video Library](https://dzone.com/events/video-library) [Refcards](https://dzone.com/refcardz) [Trend Reports](https://dzone.com/trendreports) Events [View Events](https://dzone.com/events) [Video Library](https://dzone.com/events/video-library) ### Related - [Introducing Graph Concepts in Java With Eclipse JNoSQL, Part 2: Understanding Neo4j](https://dzone.com/articles/graph-concepts-java-eclipse-jnosql-neo4j) - [Spring Data Neo4j: How to Update an Entity](https://dzone.com/articles/spring-data-neo4j-how-to-update-an-entity) - [Leveraging Neo4j for Effective Identity Access Management](https://dzone.com/articles/leveraging-neo4j-for-identity-access-management) - [The Beginner's Guide To Understanding Graph Databases](https://dzone.com/articles/the-beginners-guide-to-understanding-graph-databas) ### Trending - [Stateful AI: Streaming Long-Term Agent Memory With Amazon Kinesis](https://dzone.com/articles/streaming-agent-memory-kinesis) - [Building a Video Evidence Layer: Moment Indexing With Timecoded Retrieval](https://dzone.com/articles/building-a-video-evidence-layer-moment-indexing-wi) - [Secure Managed File Transfer vs APIs in Cloud Services](https://dzone.com/articles/secure-managed-file-transfer-vs-apis-cloud-services) - [Deploying Java applications on Arm64 with Kubernetes](https://dzone.com/articles/deploying-java-applications-on-arm64) 1. [DZone](https://dzone.com/) 2. [Data Engineering](https://dzone.com/data-engineering) 3. [Databases](https://dzone.com/databases) 4. Neo4j: COLLECTing Multiple Values (Too Many Parameters for Function ‘Collect’) # Neo4j: COLLECTing Multiple Values (Too Many Parameters for Function ‘Collect’) ### By ![Mark Needham user avatar](https://dz2cdn1.dzone.com/thumbnail?fid=4943683&w=80) [Mark Needham](https://dzone.com/users/387289/markhneedham.html) · Oct. 13, 14 · Interview Likes (0) Comment Save [Tweet](https://dzone.com/articles/neo4j-collecting-multiple) [Share](https://www.linkedin.com/sharing/share-offsite/?url=https://dzone.com/articles/neo4j-collecting-multiple) 10\.2K Views Join the DZone community and get the full member experience. [Join For Free](https://dzone.com/static/registration.html) One of my favourite functions in Neo4j’s cypher query language is COLLECT which allows us to group items into an array for later consumption. However, I’ve noticed that people sometimes have trouble working out how to collect multiple items with COLLECT and struggle to find a way to do so. Consider the following data set: ``` create (p:Person {name: "Mark"}) create (e1:Event {name: "Event1", timestamp: 1234}) create (e2:Event {name: "Event2", timestamp: 4567})   create (p)-[:EVENT]->(e1) create (p)-[:EVENT]->(e2) ``` If we wanted to return each person along with a collection of the event names they’d participated in we could write the following: ``` $ MATCH (p:Person)-[:EVENT]->(e) > RETURN p, COLLECT(e.name); +--------------------------------------------+ | p | COLLECT(e.name) | +--------------------------------------------+ | Node[0]{name:"Mark"} | ["Event1","Event2"] | +--------------------------------------------+ 1 row ``` That works nicely, but what about if we want to collect the event name and the timestamp but don’t want to return the entire event node? An approach I’ve seen a few people try during workshops is the following: ``` MATCH (p:Person)-[:EVENT]->(e) RETURN p, COLLECT(e.name, e.timestamp) ``` Unfortunately this doesn’t compile: ``` SyntaxException: Too many parameters for function 'collect' (line 2, column 11) "RETURN p, COLLECT(e.name, e.timestamp)" ^ ``` As the error message suggests, the COLLECT function only takes one argument so we need to find another way to solve our problem. One way is to put the two values into a literal array which will result in an array of arrays as our return result: ``` $ MATCH (p:Person)-[:EVENT]->(e) > RETURN p, COLLECT([e.name, e.timestamp]); +----------------------------------------------------------+ | p | COLLECT([e.name, e.timestamp]) | +----------------------------------------------------------+ | Node[0]{name:"Mark"} | [["Event1",1234],["Event2",4567]] | +----------------------------------------------------------+ 1 row ``` The annoying thing about this approach is that as you add more items you’ll forget in which position you’ve put each bit of data so I think a preferable approach is to collect a map of items instead: ``` $ MATCH (p:Person)-[:EVENT]->(e) > RETURN p, COLLECT({eventName: e.name, eventTimestamp: e.timestamp}); +--------------------------------------------------------------------------------------------------------------------------+ | p | COLLECT({eventName: e.name, eventTimestamp: e.timestamp}) | +--------------------------------------------------------------------------------------------------------------------------+ | Node[0]{name:"Mark"} | [{eventName -> "Event1", eventTimestamp -> 1234},{eventName -> "Event2", eventTimestamp -> 4567}] | +--------------------------------------------------------------------------------------------------------------------------+ 1 row ``` During the [Clojure Neo4j Hackathon](http://www.meetup.com/graphdb-london/events/194308602/) that we ran earlier this week this proved to be a particularly pleasing approach as we could easily destructure the collection of maps in our Clojure code. Neo4j Published at DZone with permission of Mark Needham. [See the original article here.](http://www.markhneedham.com/blog/2014/09/26/neo4j-collecting-multiple-values-too-many-parameters-for-function-collect/) Opinions expressed by DZone contributors are their own. ### Related - Introducing Graph Concepts in Java With Eclipse JNoSQL, Part 2: Understanding Neo4j - Spring Data Neo4j: How to Update an Entity - Leveraging Neo4j for Effective Identity Access Management - The Beginner's Guide To Understanding Graph Databases ## Partner Resources × *** Comments The likes didn't load as expected. Please refresh the page and try again. ABOUT US - [About DZone](https://dzone.com/pages/about) - [Support and feedback](https://dzone.com/cdn-cgi/l/email-protection#1f6c6a6f6f706d6b5f7b6570717a317c7072) - [Community research](https://dzone.com/pages/dzone-community-research) ADVERTISE - [Advertise with DZone](https://advertise.dzone.com/) CONTRIBUTE ON DZONE - [Article Submission Guidelines](https://dzone.com/articles/dzones-article-submission-guidelines) - [Become a Contributor](https://dzone.com/pages/contribute) - [Core Program](https://dzone.com/pages/core) - [Visit the Writers' Zone](https://dzone.com/writers-zone) LEGAL - [Terms of Service](https://technologyadvice.com/terms-conditions/) - [Privacy Policy](https://technologyadvice.com/privacy-policy/) CONTACT US - 3343 Perimeter Hill Drive - Suite 215 - Nashville, TN 37211 - [\[email protected\]](https://dzone.com/cdn-cgi/l/email-protection#186b6d6868776a6c587c6277767d367b7775) Let's be friends:
Readable Markdown
Likes (0) Save 10\.2K Views Join the DZone community and get the full member experience. [Join For Free](https://dzone.com/static/registration.html) One of my favourite functions in Neo4j’s cypher query language is COLLECT which allows us to group items into an array for later consumption. However, I’ve noticed that people sometimes have trouble working out how to collect multiple items with COLLECT and struggle to find a way to do so. Consider the following data set: ``` create (p:Person {name: "Mark"}) create (e1:Event {name: "Event1", timestamp: 1234}) create (e2:Event {name: "Event2", timestamp: 4567})   create (p)-[:EVENT]->(e1) create (p)-[:EVENT]->(e2) ``` If we wanted to return each person along with a collection of the event names they’d participated in we could write the following: ``` $ MATCH (p:Person)-[:EVENT]->(e) > RETURN p, COLLECT(e.name); +--------------------------------------------+ | p | COLLECT(e.name) | +--------------------------------------------+ | Node[0]{name:"Mark"} | ["Event1","Event2"] | +--------------------------------------------+ 1 row ``` That works nicely, but what about if we want to collect the event name and the timestamp but don’t want to return the entire event node? An approach I’ve seen a few people try during workshops is the following: ``` MATCH (p:Person)-[:EVENT]->(e) RETURN p, COLLECT(e.name, e.timestamp) ``` Unfortunately this doesn’t compile: ``` SyntaxException: Too many parameters for function 'collect' (line 2, column 11) "RETURN p, COLLECT(e.name, e.timestamp)" ^ ``` As the error message suggests, the COLLECT function only takes one argument so we need to find another way to solve our problem. One way is to put the two values into a literal array which will result in an array of arrays as our return result: ``` $ MATCH (p:Person)-[:EVENT]->(e) > RETURN p, COLLECT([e.name, e.timestamp]); +----------------------------------------------------------+ | p | COLLECT([e.name, e.timestamp]) | +----------------------------------------------------------+ | Node[0]{name:"Mark"} | [["Event1",1234],["Event2",4567]] | +----------------------------------------------------------+ 1 row ``` The annoying thing about this approach is that as you add more items you’ll forget in which position you’ve put each bit of data so I think a preferable approach is to collect a map of items instead: ``` $ MATCH (p:Person)-[:EVENT]->(e) > RETURN p, COLLECT({eventName: e.name, eventTimestamp: e.timestamp}); +--------------------------------------------------------------------------------------------------------------------------+ | p | COLLECT({eventName: e.name, eventTimestamp: e.timestamp}) | +--------------------------------------------------------------------------------------------------------------------------+ | Node[0]{name:"Mark"} | [{eventName -> "Event1", eventTimestamp -> 1234},{eventName -> "Event2", eventTimestamp -> 4567}] | +--------------------------------------------------------------------------------------------------------------------------+ 1 row ``` During the [Clojure Neo4j Hackathon](http://www.meetup.com/graphdb-london/events/194308602/) that we ran earlier this week this proved to be a particularly pleasing approach as we could easily destructure the collection of maps in our Clojure code. Neo4j
Shard102 (laksa)
Root Hash8443605588788139902
Unparsed URLcom,dzone!/articles/neo4j-collecting-multiple s443