Creating multiple nodes with mutating Cypher

407 views
Skip to first unread message

Michael Klishin

unread,
May 4, 2012, 3:53:42 PM5/4/12
to ne...@googlegroups.com
I am trying to create multiple nodes with mutating Cypher. Neo4J isn't happy with my queries and returns 400s.

Some variations on my query that I have tried:

foreach(n in {xs} : CREATE {n})
foreach(n in {xs} : CREATE a = {n} RETURN n)

where xs is a list of maps. Is what I am trying to do possible with mutating Cypher?

The exception trace in the server log says

«string matching regex `(?i)\\bstart\\b' expected but `f' found\nUnfortunately, you have run into a syntax error that we don't have a nice message for.\nBy sending the query that produced this error to cyp...@neo4j.org, you'll save the\npuppies and get better error messages in our next release.»

I am more interested in learning if what I am doing is possible than saving puppies so I decided to ask here.

MK

Michael Hunger

unread,
May 4, 2012, 3:56:43 PM5/4/12
to ne...@googlegroups.com
Michael,

that functionality just made it into cypher the other day.

create n={p}
// where p is an iterable (array, collection) of maps.

So if you have the latest 1.8-SNAPSHOT you should be able to do it.
see http://docs.neo4j.org/chunked/snapshot/query-create.html#create-create-multiple-nodes-from-map

Cheers

Michael

Michael Klishin

unread,
May 4, 2012, 4:02:39 PM5/4/12
to ne...@googlegroups.com
Michael Hunger:

> create n={p}
> // where p is an iterable (array, collection) of maps.
>
> So if you have the latest 1.8-SNAPSHOT you should be able to do it.

Yes, I am able to create individual nodes with 1.8 M01 and was wondering about doing it for iterables.

Trying the line you've provided above, I get

«org.neo4j.cypher.CypherTypeException: Don't know how to extract parameters from this type: java.util.ArrayList»

back at

org.neo4j.cypher.internal.mutation.GraphElementPropertyFunctions$class.getMapFromExpression(UpdateAction.scala:85)

MK

Michael Klishin

unread,
May 4, 2012, 4:03:28 PM5/4/12
to ne...@googlegroups.com
Michael Hunger:

> if you have the latest 1.8-SNAPSHOT you should be able to do it.

I am using 1.8-M01. Should I be using snapshots?

MK

Michael Hunger

unread,
May 4, 2012, 4:07:53 PM5/4/12
to ne...@googlegroups.com
This functionality is not in M01 it just made it in yesterday, so if you need this, yes or you have to wait for M02.

Michael

Michael Klishin

unread,
May 4, 2012, 4:24:55 PM5/4/12
to ne...@googlegroups.com
Michael Hunger:

> So if you have the latest 1.8-SNAPSHOT you should be able to do it.
> see http://docs.neo4j.org/chunked/snapshot/query-create.html#create-create-multiple-nodes-from-map

I can confirm that it works with the snapshot version. Very nice!

MK


Andres Taylor

unread,
May 4, 2012, 4:25:32 PM5/4/12
to ne...@googlegroups.com


On Fri, May 4, 2012 at 10:12 PM, Michael Klishin <michael....@gmail.com> wrote:
Michael Hunger:


> This functionality is not in M01 it just made it in yesterday, so if you need this, yes or you have to wait for M02.

I see. neo4j.org downloads page suggests the most recent snapshot is from April. Is this true? should I build from
source then?

That's weird. We push out snapshot from our CI build. I just checked downloaded the Unix version, and it contains binaries produced a few hours ago. 

We'll check why the date on the page is wrong...

Andrés 

Michael Klishin

unread,
May 4, 2012, 4:12:19 PM5/4/12
to ne...@googlegroups.com
Michael Hunger:

> This functionality is not in M01 it just made it in yesterday, so if you need this, yes or you have to wait for M02.

I see. neo4j.org downloads page suggests the most recent snapshot is from April. Is this true? should I build from
source then?

https://skitch.com/michaelklishin/82y93/neo4j-worlds-leading-graph-database-download

MK

Reply all
Reply to author
Forward
0 new messages