Re: [Neo4j] Searching within relationships

2010-07-17 Thread Peter Soung
Here's some additional context.  I'm using Neo4j to store connections between 
different contacts in different network groups.  As a simple example, User A 
may be connected to User B in Network A and Network B, but not Network C.  This 
would be represented by 2 nodes (one for each user) and 2 relationships (one 
for Network A and one for Network B).   Each user has several internal 
properties, such as name, network IDs, etc.  With that said, I would like to be 
able to search within all of a user's contacts (i.e. anyone with a specified 
relationship).  For example, I want to find anyone with the name = Bob that 
is connected to the user with ID = 123.  You can assume that all of the 
aforementioned internal properties for a user are indexed.  

Another possible use case is this: show me anyone connected to the user with ID 
= 123 and sort those contacts by users with the most outgoing relationships.

Hopefully that provides enough context to our use of Neo4j and the use cases 
we're looking to support.  Do either/both of those scenarios sound feasible?

Thanks,
Peter

 Hi Peter,
 
 Just to understand the issue at hand, what does your graph look like? What
 problem do you want to solve? Do you have User nodes connected with some
 type of relationship, and want to find all users connected to a given user,
 who e.g. have an age property with a value greater than 30? Also, what are
 you indexing?
 
 David
 
 On Fri, Jul 16, 2010 at 2:44 PM, Peter Soung pe...@sproutsocial.com wrote:
 
 Hello,
 Is there a high-performance way to search/lookup users within the
 relationships of a given user?  This is assuming that the relevant
 properties have been indexed.
 
 Thanks,
 Peter
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Searching within relationships

2010-07-17 Thread Marko Rodriguez
Hi,

 Here's some additional context.  I'm using Neo4j to store connections between 
 different contacts in different network groups.  As a simple example, User A 
 may be connected to User B in Network A and Network B, but not Network C.  
 This would be represented by 2 nodes (one for each user) and 2 relationships 
 (one for Network A and one for Network B).   Each user has several internal 
 properties, such as name, network IDs, etc.  With that said, I would like to 
 be able to search within all of a user's contacts (i.e. anyone with a 
 specified relationship).  For example, I want to find anyone with the name = 
 Bob that is connected to the user with ID = 123.  You can assume that all 
 of the aforementioned internal properties for a user are indexed.  
 
 Another possible use case is this: show me anyone connected to the user with 
 ID = 123 and sort those contacts by users with the most outgoing 
 relationships.


If you are interested, I would do this in Gremlin 0.2.2 
[http://gremlin.tinkerpop.com] as such:

FIRST SCENARIO: g:key('name','Bob')/outE/i...@id=123]/../..

SECOND SCENARIO: 
$m := g:map()
$_g/V/outE/i...@id=123]/../..[g:op-value('+',$m,.,count(./outE))]
g:sort($m,'value')

Or, as a for-loop:

$m := g:map()
foreach $v in $_g/V
if count($v/outE/i...@id=123])  0
g:assign($m,$v,count($v/outE))
end
end
g:sort($m,'value')

I just wrote these off the top of my head so they may contain bugs.

See ya,
Marko.

http://markorodriguez.com

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Searching within relationships

2010-07-17 Thread David Montag
Hi Peter,

Those use cases do sound feasible. The first one, finding all of 123's
friends named Bob, you can do in different ways. You could iterate the
relationships on 123 finding the friends and do the filtering/matching
manually, or you could do a depth 1 traversal with some constraints,
or, depending on the nature of the indexed property, find all nodes
with name Bob and see if they are connected to 123.

For the other use case, list 123's friends sorted by friend count, you
can do a depth 1 traversal or manually iterate over the relationships
of 123, and then use an intermediate data structure to do the sorting
of the data you gathered in it. Indexing won't help you here, unless
you store the number of friends as a precomputed or eventually
computed property on the users.

Marko's suggestions using Gremlin makes it a lot less verbose, but
it's also good to know how to do it using the APIs.

David

Sent from cell, excuse typos etc etc

On Saturday, July 17, 2010, Peter Soung pe...@sproutsocial.com wrote:
 Here's some additional context.  I'm using Neo4j to store connections between 
 different contacts in different network groups.  As a simple example, User A 
 may be connected to User B in Network A and Network B, but not Network C.  
 This would be represented by 2 nodes (one for each user) and 2 relationships 
 (one for Network A and one for Network B).   Each user has several internal 
 properties, such as name, network IDs, etc.  With that said, I would like to 
 be able to search within all of a user's contacts (i.e. anyone with a 
 specified relationship).  For example, I want to find anyone with the name = 
 Bob that is connected to the user with ID = 123.  You can assume that all 
 of the aforementioned internal properties for a user are indexed.

 Another possible use case is this: show me anyone connected to the user with 
 ID = 123 and sort those contacts by users with the most outgoing 
 relationships.

 Hopefully that provides enough context to our use of Neo4j and the use cases 
 we're looking to support.  Do either/both of those scenarios sound feasible?

 Thanks,
 Peter

 Hi Peter,

 Just to understand the issue at hand, what does your graph look like? What
 problem do you want to solve? Do you have User nodes connected with some
 type of relationship, and want to find all users connected to a given user,
 who e.g. have an age property with a value greater than 30? Also, what are
 you indexing?

 David

 On Fri, Jul 16, 2010 at 2:44 PM, Peter Soung pe...@sproutsocial.com wrote:

 Hello,
 Is there a high-performance way to search/lookup users within the
 relationships of a given user?  This is assuming that the relevant
 properties have been indexed.

 Thanks,
 Peter
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


[Neo4j] Searching within relationships

2010-07-16 Thread Peter Soung
Hello,
Is there a high-performance way to search/lookup users within the relationships 
of a given user?  This is assuming that the relevant properties have been 
indexed.

Thanks,
Peter
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Searching within relationships

2010-07-16 Thread David Montag
Hi Peter,

Just to understand the issue at hand, what does your graph look like? What
problem do you want to solve? Do you have User nodes connected with some
type of relationship, and want to find all users connected to a given user,
who e.g. have an age property with a value greater than 30? Also, what are
you indexing?

David

On Fri, Jul 16, 2010 at 2:44 PM, Peter Soung pe...@sproutsocial.com wrote:

 Hello,
 Is there a high-performance way to search/lookup users within the
 relationships of a given user?  This is assuming that the relevant
 properties have been indexed.

 Thanks,
 Peter
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user