Thanks Andrés!

Couple of random extensions to the thoughts above:

- To be consistent, perhaps for "optional matches", the results could always
include a row where that optional match was ignored. That way, "Elizabeth,
<null>" wouldn't be an inconsistency; *every* first-degree friend would have
an "[friend], <null>" row.

- And perhaps *that* row could be the one that has the full node data, and
every subsequent row for the second optional match would just reference the
URL/ID of the first-degree node.

After chewing on this a lot more, though, I've realized that what I really
want in this scenario is not tabular data, but a real subgraph. Hence my
email just now. =)

Aseem

On Thu, Aug 25, 2011 at 1:34 PM, Andres Taylor <
andres.tay...@neotechnology.com> wrote:

> Good and valid requests, Aseem.
>
> Consider them heard. We'll see how soon we can get it to you.
>
> Andrés
>
> On Thu, Aug 25, 2011 at 12:57 PM, Aseem Kishore <aseem.kish...@gmail.com
> >wrote:
>
> > Man, I am loving Cypher. Thanks so much guys for introducing it. I'm a
> bit
> > stuck on one query, though, and I wanted to ask for help. I think the
> > reasons I'm stuck are related to the two feature requests I made
> yesterday
> > (optional matches, and returning IDs).
> >
> > I want to fetch first- and second-degree friends in one query, in a way
> > that
> > preserves the first-degree friend(s) for each second-degree friends.
> Assume
> > an asymmetrical friendship model, like Twitter's following, because that
> > makes things a bit easier.
> >
> > Here's a simple transitive example:
> >
> > - Alice follows Bob and Carol.
> > - Bob follows Carol and Dave.
> > - Carol follows Dave and Alice.
> >
> >
> > I want to fetch Alice's first-degree friends (Bob and Carol) and each of
> > their first-degree friends ((Carol and Dave) for Bob, and (Dave and
> Alice)
> > for Carol). This example is easy enough:
> >
> > START zero=(Alice)
> > MATCH (zero) -[:FOLLOWS]-> (first) -[:FOLLOWS]-> (second)
> > RETURN first, second
> >
> >
> > I expect to get back results like:
> >
> > - Bob, Carol
> > - Bob, Dave
> > - Carol, Dave
> > - Carol, Alice
> >
> >
> > This is great because I can get Alice's first-degree friends by
> > unique()'ing
> > the first column, for each person, I know their second-degree friends via
> > the second column.
> >
> > But this doesn't work if any of my first-degree friends don't follow
> > anyone.
> > For that, it would be great if I could specify that the second part of
> that
> > match was "optional", and I'd get back a row like this in that case:
> >
> > - Elizabeth, <null>
> >
> > If I'm returning nodes, it also duplicates a ton of info: each
> first-degree
> > friend's info is returned in full for each of their friends. Maybe
> there's
> > no way around that, but this is also where I would find it convenient to
> be
> > able to return IDs somehow for all but one of the results.
> >
> > Just thinking out loud here, but I'd greatly appreciate any feedback or
> > ideas for this scenario. Thanks much!
> >
> > Aseem
> > _______________________________________________
> > 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 mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to