On Fri, Aug 3, 2012 at 1:02 AM, Josh Adell <josh.ad
...@gmail.com> wrote:
> This is what I have so far:
> http://console.neo4j.org/?id=yj9cwv
> I think I'm getting a parse error because it doesn't like the string
> concatenation in 'next=node:node_auto_index("first:"+named.last)'
> -- Josh
> On Thursday, August 2, 2012 3:54:05 AM UTC-4, Michael Hunger wrote:
>> I think in this case you don't need foreach in this case:
>> > START named=node:names("first:*")
>> WITH named
>> > START next=node:names("first: " + current.last), prev=node:names("last:
>> > " + current.first)
>> > RELATE current -[:LEADS_TO]-> next
>> > RELATE prev -[:LEADS_TO]-> current
>> Hope that works.
>> Can you try to create a console example that we can work on? (The console
>> is auto-indexing each property so if you create a node with the first and
>> last properties you should find them in the node_auto_index)
>> Michael
>> Am 02.08.2012 um 05:20 schrieb Josh Adell:
>> > So I have a list of name nodes in an index called "names":
>> > "foo bar"
>> > "bar baz"
>> > "baz qux"
>> > "bar qux"
>> > "qux foo"
>> > Each name node is indexed with a key "first" which is the first word in
>> > the name, and "last" which is the last word in the name, and each node has
>> > properties on it containing the first and last words. The following Cypher
>> > works:
>> > START named=node:names("first:bar") RETURN named.name
>> > returns "bar baz" and "bar qux". So all that is working
>> > Now what I want to do is use Cypher to link together the name nodes such
>> > that the last word of a node is the first word of the outgoing node. In the
>> > end, I should have a graph that looks like:
>> > "foo bar" --> "bar baz"
>> > "foo bar" --> "bar qux"
>> > "bar baz" --> "baz qux"
>> > etc...
>> > I think I should be able to do this in Cypher with FOREACH and RELATE,
>> > but I'm unsure of the exact syntax. The following is semantically what I
>> > want, but is not syntactically correct:
>> > START named=node:names("first:*")
>> > FOREACH (current in nodes(named):
>> > START next=node:names("first: " + current.last),
>> > prev=node:names("last: " + current.first)
>> > RELATE current -[:LEADS_TO]-> next
>> > RELATE prev -[:LEADS_TO]-> current
>> > )
>> > I could do this all in the application, but I was hoping for a more
>> > elegant solution using Cypher (preferably one that is idempotent.)
>> > Any ideas?
>> > Thanks!
>> > -- Josh