Trey,
I think you could use COALESCE,
http://docs.neo4j.org/chunked/snapshot/query-function.html#_predicates,
and then even compose your query into several parts with WITH, see
http://docs.neo4j.org/chunked/snapshot/query-with.html in order to
take your calculated return, something like
START n=node(99)
MATCH n-[r1:likes|eats]-(c)-[r2:likes|eats]-x WHERE type(r1)=type(r2)
return
x.name as name, (r2.weight + COALESCE(r2.activity?, 0)) as
boost LIMIT 10;
Does that work?
Cheers,
/peter neubauer
G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L:
http://www.linkedin.com/in/neubauer
T: @peterneubauer
If you can write, you can code - @coderdojomalmo
If you can sketch, you can use a graph database - @neo4j
On Wed, Jun 6, 2012 at 8:57 PM, Trey Sandworm <
timbr...@gmail.com> wrote:
> I've been looking at manuals about this and still can't figure out if I can
> do it, and if so, how. I would greatly appreciate help with it.
>
> In all my relationship types I have a property called 'weight'.
> In only 1 relationship type I have a property called 'activity'.
>
> I'm trying to return something like this
>
> START n=node(99) MATCH n-[r1:likes|eats]-(c)-[r2:likes|eats]-x WHERE
> type(r1)=type(r2) RETURN
x.name, (r2.weight + r2.activity) as boost LIMIT
> 10;
>
> The problem is that I can't do any operation on activity because it's a
> property of only 1 relationship type.
> Ideally I need to accomplish something like:
>
> (r2.weight + if (has(r2.activity) then r2.activity else 0))
>
> putting 'r2.activity?' in RETURN works partially in at least listing the
> activity as NULL, but I would like to do operations with it as above as
> well.
>
> Is there any way to specify myself a default value for non existent
> r2.activity, similarly like r2.activity? lists it as NULL, but then also
> being able to do mathematical calculations as well?
>
> Thanks in advance