Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Using RELATE with multiple index lookups
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Josh Adell  
View profile  
 More options Aug 1 2012, 11:20 pm
From: Josh Adell <josh.ad...@gmail.com>
Date: Wed, 1 Aug 2012 20:20:24 -0700 (PDT)
Local: Wed, Aug 1 2012 11:20 pm
Subject: Using RELATE with multiple index lookups

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Hunger  
View profile  
 More options Aug 2 2012, 3:54 am
From: Michael Hunger <michael.hun...@neotechnology.com>
Date: Thu, 2 Aug 2012 09:54:05 +0200
Local: Thurs, Aug 2 2012 3:54 am
Subject: Re: [Neo4j] Using RELATE with multiple index lookups
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Josh Adell  
View profile  
 More options Aug 2 2012, 7:02 pm
From: Josh Adell <josh.ad...@gmail.com>
Date: Thu, 2 Aug 2012 16:02:58 -0700 (PDT)
Local: Thurs, Aug 2 2012 7:02 pm
Subject: Re: [Neo4j] Using RELATE with multiple index lookups

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Neubauer  
View profile  
 More options Aug 20 2012, 10:21 am
From: Peter Neubauer <peter.neuba...@neotechnology.com>
Date: Mon, 20 Aug 2012 16:21:55 +0200
Local: Mon, Aug 20 2012 10:21 am
Subject: Re: [Neo4j] Using RELATE with multiple index lookups
Guys,
is this something that should be possible - use identifiers and
functions in the index calls? Andres?

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Wanna learn something new? Come to @graphconnect.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »