HI Michael,

Thanks for this solution. The webconsole now gives me the right results
also for recommendation query. There is however still something weird when
I use this recommendation query in the gremlin console:

gremlin> node = g.v(14260); m = [:].withDefault{0.0}; a_total =
node.inE().count(); node.in().out('owns').sideEffect{union = a_total +
it.inE().count()}.groupCount(m) { it : it += (1.0/(union)) } >> -1;
m.sort{a,b -> b.value <=> a.value}[0..9]
No signature of method:
com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex.plus() is applicable
for argument types: (java.math.BigDecimal) values: [0.0303030303]
Possible solutions: values(), keys(), use([Ljava.lang.Object;),
values(java.lang.Object), is(java.lang.Object), split(groovy.lang.Closure)

The weird thing is that exact same query does work in the webconsole..

Consider my issue solved though. Thanks a lot.

Jeroen

On Mon, Nov 7, 2011 at 1:25 PM, Michael Hunger <
michael.hun...@neotechnology.com> wrote:

> Jeroen,
>
> could you try to use the alternative syntax:
>
> ... groupCount(m) { it : it += 0.1 } ...
>
> It seems to be a problem with evaluation of the string in the
> javax.ScriptEngine for Groovy
>
> Here is the output from my web-console:
>        • gremlin> m = [:];g.v(33).bothE().label.groupCount(m) { it }{ it
> += 0.1 } >> -1;m
>        • ==> follows=11
>        • ==> owns=48
>        • gremlin> m = [:];g.v(33).bothE().label.groupCount(m) { it : it +=
> 0.1 } >> -1;m
>        • ==> follows=1.1
>        • ==> owns=4.8
>
> Michael
>
> Am 07.11.2011 um 12:55 schrieb Jeroen van Dijk:
>
> > Ok i think I found an example that is independent of my data (adapted
> from
> > http://docs.neo4j.org/chunked/snapshot/gremlin-plugin.html)
> >
> > Locally:
> > gremlin> m = [:];g.v(33).bothE().label.groupCount(m) >> -1;m
> >
> > ==>follows=11
> > ==>owns=48
> > gremlin> m = [:];g.v(33).bothE().label.groupCount(m) { it }{ it += 0.1 }
> >>
> > -1;m
> > ==>follows=1.1
> > ==>owns=4.8
> >
> > REST/webadmin console:
> > gremlin> m = [:];g.v(33).bothE().label.groupCount(m) { it }{ it += 0.1 }
> >>
> > -1;m
> > ==> follows=11
> > ==> owns=48
> > gremlin> m = [:];g.v(33).bothE().label.groupCount(m) { it }{ it += 10 }
> >>
> > -1;m
> > ==> follows=11
> > ==> owns=48
> > gremlin>
> >
> > It seems like the closure block is not evaluated (to me as a
> > Groovy/Gremlin/Neo4j noob)
> >
> > Michael, I will send you a link to my database in private.
> >
> > Thanks,
> > Jeroen
> >
> >
> >
> > On Mon, Nov 7, 2011 at 12:41 PM, Michael Hunger <
> > michael.hun...@neotechnology.com> wrote:
> >
> >> Jeroen,
> >>
> >> that would indeed help a lot.
> >> I'll find it.
> >>
> >> Michael
> >>
> >> Am 07.11.2011 um 12:34 schrieb Jeroen van Dijk:
> >>
> >>> Hi Michael,
> >>>
> >>> I would like to provide a better example, but my Groovy is quite poor
> so
> >> it
> >>> I'll take me some time. However I think the problem isn't in the JSON
> >>> conversion. Because that would mean the results I get would be the
> same,
> >>> but with a different score right? The thing is that I get different
> >>> Vertices back through the REST interface than I do locally. To me that
> >>> means things already fail during the Gremlin evaluation.
> >>>
> >>> I will try to come up with a more isolated example. If it helps I could
> >>> give you access to my dataset on Heroku (or through a Zip file).
> >>>
> >>> thanks,
> >>> Jeroen
> >>>
> >>> On Mon, Nov 7, 2011 at 11:34 AM, Michael Hunger <
> >>> michael.hun...@neotechnology.com> wrote:
> >>>
> >>>> Jeroen,
> >>>>
> >>>> can you narrow it down to a simpler operation, like just a division?
> >>>>
> >>>> Perhaps in the conversion from the division result (be it Float,
> Double,
> >>>> BigDecimal) to
> >>>> JSON something goes awry.
> >>>>
> >>>> In the GremlinPlugin the code for that is:
> >>>>
> >>>> } else if (result instanceof Double || result instanceof Float) {
> >>>>          return ValueRepresentation.number(((Number)
> >>>> result).doubleValue());
> >>>> }
> >>>>
> >>>> I'm not sure what datatype groovy creates as result of your operation,
> >>>> perhaps you can determine that as well.
> >>>>
> >>>> If we have a simple gremlin / groovy calculation that yields the wrong
> >>>> results, we can easily inspect and fix the plugin.
> >>>>
> >>>> Thanks a lot
> >>>>
> >>>> Michael
> >>>>
> >>>> Am 07.11.2011 um 11:12 schrieb Jeroen van Dijk:
> >>>>
> >>>>> Hi all,
> >>>>>
> >>>>> I'm using Gremlin to perform a recommendation query. Locally in the
> >>>> gremlin
> >>>>> shell I get amazingly useful results. However when I use the webadmin
> >>>>> gremlin console I get different results, both locally and in the
> Heroku
> >>>>> addon environment. I get the same wrong results when I use the rest
> >>>>> interface, so I assume something is incorrect in the Gremlin REST
> >>>>> interface. In all these cases the data is the same or on the same
> >>>> database.
> >>>>>
> >>>>> The gremlin query is below (it is own of my first so probably not the
> >>>> most
> >>>>> efficient). It returns the top 10 list of most similar items
> according
> >> to
> >>>>> the Jaccard similarity index (= (Intersection(A, B) / Union(A, B) ):
> >>>>>
> >>>>> node = g.v(14260); m = [:].withDefault{0.0}; a_total =
> >>>> node.inE().count();
> >>>>> node.in().out('owns').sideEffect{union = a_total +
> >>>>> it.inE().count()}.groupCount(m) { it }{ it += (1/(union)) } >> -1;
> >>>>> m.sort{a,b -> b.value <=> a.value}[0..9]
> >>>>>
> >>>>> When I do the following locally everything is fine:
> >>>>>
> >>>>>  gremlin> g = new
> >>>>>
> >>
> Neo4jGraph('/usr/local/Cellar/neo4j/community-1.4/libexec/data/graph.db')
> >>>>>  ==>neo4jgraph[EmbeddedGraphDatabase
> >>>>> [/usr/local/Cellar/neo4j/community-1.4/libexec/data/graph.db]]
> >>>>>  gremlin> node = g.v(14260); m = [:].withDefault{0.0}; a_total =
> >>>>> node.inE().count(); node.in().out('owns').sideEffect{union =
> a_total +
> >>>>> it.inE().count()}.groupCount(m) { it }{ it += (1/(union)) } >> -1;
> >>>>> m.sort{a,b -> b.value <=> a.value}[0..9]
> >>>>>  ==>v[14260]=0.5000000013
> >>>>>  ==>v[12974]=0.1014492752
> >>>>>  ==>v[12349]=0.0952380952
> >>>>>  ==>v[12082]=0.0833333332
> >>>>>  ==>v[15434]=0.0810810810
> >>>>>  ==>v[11237]=0.0810810810
> >>>>>  ==>v[17672]=0.0769230768
> >>>>>  ==>v[18338]=0.0769230768
> >>>>>  ==>v[12852]=0.0769230768
> >>>>>  ==>v[11969]=0.075
> >>>>>  gremlin>
> >>>>>
> >>>>> However when I repeat this using the webadmin console interface I get
> >> the
> >>>>> following results:
> >>>>>
> >>>>>  gremlin> node = g.v(14260); m = [:].withDefault{0.0}; a_total =
> >>>>> node.inE().count(); node.in().out('owns').sideEffect{union =
> a_total +
> >>>>> it.inE().count()}.groupCount(m) { it }{ it += (1/(union)) } >> -1;
> >>>>> m.sort{a,b -> b.value <=> a.value}[0..9]
> >>>>>  ==> v[14260]=31.0
> >>>>>  ==> v[9204]=30.0
> >>>>>  ==> v[8958]=29.0
> >>>>>  ==> v[15763]=22.0
> >>>>>  ==> v[13906]=22.0
> >>>>>  ==> v[18477]=21.0
> >>>>>  ==> v[9081]=20.0
> >>>>>  ==> v[9019]=19.0
> >>>>>  ==> v[9074]=18.0
> >>>>>  ==> v[9066]=18.0
> >>>>>
> >>>>> The values of a Jaccard Index should never be above 1 so something is
> >>>>> clearly wrong. Any ideas?
> >>>>>
> >>>>> Thanks,
> >>>>> Jeroen
> >>>>> _______________________________________________
> >>>>> 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
> >>
> >> _______________________________________________
> >> 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
>
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to