[Neo4j] Cypher queries in python

2016-05-26 Thread Jessica Marinho
I'm migrating a postgresql database to neo4J. I am using the Python 
language, but I have a problem. I have a table called 'historico' which 
marks the rainfall recorded by a sensor in a certain latitude and 
longitude. My problem is the following: if a node with such latitude and 
longitude in my database Neo4j, I'll just create a node with precipitation 
and connect it to the existing node, otherwise I create a new node with 
latitude and longitude and connect the rainfall node to it. But I don't 
know how to compare the return of my cypher query in python for I know if 
there is a node or not. My code:

http://pastebin.com/Wbw5a9vK

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Neo4j] Guide needed for implementation of my use case

2016-05-26 Thread Reetika Malhotra
Hi all experts out there,

I am looking for a solution using neo4j for my use case where in I want to 
calculate the churn for a Telecom Company. I am a student and very new to 
nosql.

I tried this 
Node Label: Customer
Properties: Name, own phone number and contract Status: cancelled or not 
cancelled
Relationships: calls

I am unable to find a match between all the customers a Person calls who 
have not cancelled their contract.

Is there something wrong with my data model. 
Should I have 2 Labels
Or matching in one Label is possible


-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Neo4j] Cypher queries in python

2016-05-26 Thread Yayati Sule
Hi Jessica,
when you execute the query cypher query, just iterate over the cursor and
append it to a list. Then using the json.dumps() method you can get the
result in JSON format. You may then analyze it as per your needs
ᐧ

Regards,
Yayati Sule
Associate Data Scientist
Innoplexus Consulting Services Pvt. Ltd.
www.innoplexus.com
Mob : +91-9527459407

Landline: +91-20-66527300

© 2011-16 Innoplexus Consulting Services Pvt. Ltd.

Unless otherwise explicitly stated, all rights including those in
copyright in the content of this e-mail are owned by Innoplexus
Consulting Services Pvt Ltd. and all related legal entities. The
contents of this e-mail shall not be copied, reproduced, or
transmitted in any form without the written permission of Innoplexus
Consulting Services Pvt Ltd or that of the copyright owner. The
receipt of this mail is the acknowledgement of the receipt of
contents; if the recipient is not the intended addressee then the
recipient shall notify the sender immediately.

The contents are provided for information only and no opinions
expressed should be relied on without further consultation with
Innoplexus Consulting Services Pvt Ltd. and all related legal
entities. While all endeavors have been made to ensure accuracy,
Innoplexus Consulting Services Pvt. Ltd. makes no warranty or
representation to its accuracy, completeness or fairness and persons
who rely on it do so entirely at their own risk. The information
herein may be changed or withdrawn at any time without notice.
Innoplexus Consulting Services Pvt. Ltd. will not be liable to any
client or third party for the accuracy of the information supplied
through this service.

Innoplexus Consulting Services Pvt. Ltd. accepts no responsibility or
liability for the contents of any other site, whether linked to this
site or not, or any consequences from your acting upon the contents of
another site.

Please Consider the environment before printing this email.


On Thu, May 26, 2016 at 5:03 PM, Jessica Marinho 
wrote:

> I'm migrating a postgresql database to neo4J. I am using the Python
> language, but I have a problem. I have a table called 'historico' which
> marks the rainfall recorded by a sensor in a certain latitude and
> longitude. My problem is the following: if a node with such latitude and
> longitude in my database Neo4j, I'll just create a node with precipitation
> and connect it to the existing node, otherwise I create a new node with
> latitude and longitude and connect the rainfall node to it. But I don't
> know how to compare the return of my cypher query in python for I know if
> there is a node or not. My code:
>
> http://pastebin.com/Wbw5a9vK
>
> --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to neo4j+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Neo4j] Guide needed for implementation of my use case

2016-05-26 Thread Yayati Sule
Hi Reeika,
You can access the property key as follows
query:
  MATCH(n:PERSON{name:blah1,Pnumber:blah2, status:Cancelled/Not
Cancelled}) Return count(n.status)
See if this works

ᐧ

Regards,
Yayati Sule
Associate Data Scientist
Innoplexus Consulting Services Pvt. Ltd.
www.innoplexus.com
Mob : +91-9527459407

Landline: +91-20-66527300

© 2011-16 Innoplexus Consulting Services Pvt. Ltd.

Unless otherwise explicitly stated, all rights including those in
copyright in the content of this e-mail are owned by Innoplexus
Consulting Services Pvt Ltd. and all related legal entities. The
contents of this e-mail shall not be copied, reproduced, or
transmitted in any form without the written permission of Innoplexus
Consulting Services Pvt Ltd or that of the copyright owner. The
receipt of this mail is the acknowledgement of the receipt of
contents; if the recipient is not the intended addressee then the
recipient shall notify the sender immediately.

The contents are provided for information only and no opinions
expressed should be relied on without further consultation with
Innoplexus Consulting Services Pvt Ltd. and all related legal
entities. While all endeavors have been made to ensure accuracy,
Innoplexus Consulting Services Pvt. Ltd. makes no warranty or
representation to its accuracy, completeness or fairness and persons
who rely on it do so entirely at their own risk. The information
herein may be changed or withdrawn at any time without notice.
Innoplexus Consulting Services Pvt. Ltd. will not be liable to any
client or third party for the accuracy of the information supplied
through this service.

Innoplexus Consulting Services Pvt. Ltd. accepts no responsibility or
liability for the contents of any other site, whether linked to this
site or not, or any consequences from your acting upon the contents of
another site.

Please Consider the environment before printing this email.


On Wed, May 25, 2016 at 3:56 PM, Reetika Malhotra  wrote:

> Hi all experts out there,
>
> I am looking for a solution using neo4j for my use case where in I want to
> calculate the churn for a Telecom Company. I am a student and very new to
> nosql.
>
> I tried this
> Node Label: Customer
> Properties: Name, own phone number and contract Status: cancelled or not
> cancelled
> Relationships: calls
>
> I am unable to find a match between all the customers a Person calls who
> have not cancelled their contract.
>
> Is there something wrong with my data model.
> Should I have 2 Labels
> Or matching in one Label is possible
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to neo4j+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Neo4j] Re: Slow node creation/commits with unique constraint in 2.0.0

2016-05-26 Thread Eric Fulton
So before the constraint, I was still using merges because I really did 
want something akin to uniqueness for these nodes.  We had an index on the 
"uid" so maybe that helped with the full scan?
Yes, I use parameters, not literal values.  

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Neo4j] Visuaization Tool for Neo4J

2016-05-26 Thread Sukaant Chaudhary
Thankyou everyone for the help!

-Sukaant Chaudhary


On Sun, May 22, 2016 at 9:24 PM, 'Michael Hunger' via Neo4j <
neo4j@googlegroups.com> wrote:

> Max De Marzi has a ton of write-ups on Data Visualization:
> https://maxdemarzi.com/tag/visualization-2/
>
> My colleague Will has been working on a visualization example too (built
> on viz.js): https://github.com/johnymontana/neovis.js
>
> For Python Nicole White has a good notebook:
> http://nicolewhite.github.io/neo4j-jupyter/hello-world.html
>
> And I recently did one with vivagraph.js:
> neo4j.com/blog/neo4j-3-0-graph-universe/
>
> > Am 22.05.2016 um 04:23 schrieb Sumit Gupta :
> >
> > This may help you - http://neo4j.com/developer/guide-data-visualization/
> >
> > On Saturday, 21 May 2016 02:42:12 UTC+5:30, Sukaant Chaudhary wrote:
> > Hi,
> > Can anyone suggest me some open source tool which is free for graph
> visualization in neo4j.
> >
> > Thanks for any help!
> >
> > -Sukaant Chaudhary
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Neo4j" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to neo4j+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to neo4j+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Neo4j] Go through all the transitive relationships in the database

2016-05-26 Thread Cherie Pun
I am trying to find an efficient way of traversing all nodes and find 
transitive relationships of length 2 on my database. Currently, I am using 
query1 to compute the new properties for the new relationship and query 2 
to add the relationship into the database

query1:
MATCH (a:USERS) - [ab:TRUST] -> (b:a:USERS) - [bc:TRUST] -> (c:a:USERS)
WHERE a <> c AND exists(ab.conversationalTrust) AND exists(bc.
conversationalTrust)
WITH id(a) AS a, id(c) AS c, ab.conversationalTrust AS ab, 
bc.conversationalTrust 
AS bc
WITH a, c, sum(ab*bc)/ sum(ab) AS t1, sum(ab*ab*bc)/ sum(ab) AS t2, 10^4 AS 
factor
RETURN a, c, round(factor * t1)/factor AS simpleTransitiveTrust, round(factor 
* t2)/factor AS weightedTranstiveTrust;

Java code that pack the above results into batches and pass it to query 2

long userAId = (long) map.get("a");
long userBId = (long) map.get("c");
double simpleTransitiveTrust = (double) map.get(TwitterProperties.
SIMPLE_TRANSITIVE_TRUST);
double weightedTransitiveTrust = (double) map.get(TwitterProperties.
WEIGHTED_TRANSITIVE_TRUST);
Object[] params = {userAId, userBId, simpleTransitiveTrust, 
weightedTransitiveTrust};
return params;


query2:
UNWIND {params} as params
MATCH (a:USERS),(b:USERS)
WHERE id(a) = params[0] and id(b) = params[1]
MERGE (a) - [r:TRUST] -> (b)
SET r.simpleTransitiveTrust= params[2], r.weightedTranstiveTrust= params[3]
RETURN count(*) as c



I have two questions:
1) Is it more efficient to do everything in Cypher, i.e. combine query 1 
and query 2?

2) Is the above way the best way to go through all transitive 
relationships? Since I have more than 500k nodes in my database, it takes a 
very long time to process everything, so I am hoping there's a way to speed 
it up. Would the traversal framework in java be of any use? If so, how 
should I use it in this case.

3) Without specifying where to start, does neo4j automatically goes through 
all possible pairs of nodes for a and c to find transitive relationships 
between them? 

Thank you very much in advance for helping me out.

Cheers,
Cherie

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Neo4j] Re: Slow node creation/commits with unique constraint in 2.0.0

2016-05-26 Thread 'Michael Hunger' via Neo4j
Can you share the query plan from before and after the constraint?

Oh if you had an index on uid then you had the benefit of the "fast scan" but 
without the penalty of "asserting uniqueness across the index".

Michael

> Am 26.05.2016 um 18:25 schrieb Eric Fulton :
> 
> So before the constraint, I was still using merges because I really did want 
> something akin to uniqueness for these nodes.  We had an index on the "uid" 
> so maybe that helped with the full scan?
> Yes, I use parameters, not literal values.  
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to neo4j+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Neo4j] Re: Slow node creation/commits with unique constraint in 2.0.0

2016-05-26 Thread Eric Fulton
I'm sorry, I'm not sure exactly what you mean by query scan.  I haven't 
changed any of the queries from before the addition of the uniqueness 
constraint.  I'm still doing the same "MERGE ..." query (like above, but 
with parameters, as you pointed out).  Do you mean that, or something else?

Thanks!
Eric

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Neo4j] Slow node creation/commits with unique constraint in 2.0.0

2016-05-26 Thread 'Michael Hunger' via Neo4j
I meant:

with an index you the fast lookup but no pentalty
with an constraint you have the uniqueness guarantee via a lock and check 
against the constraint on write, both of which cost.

But I ask if that can be alleviated.

Could you test it in 3.0.2 if it performs better?

Michael

> Am 27.05.2016 um 00:29 schrieb Eric Fulton :
> 
> I'm sorry, I'm not sure exactly what you mean by query scan.  I haven't 
> changed any of the queries from before the addition of the uniqueness 
> constraint.  I'm still doing the same "MERGE ..." query (like above, but with 
> parameters, as you pointed out).  Do you mean that, or something else?
> 
> Thanks!
> Eric
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to neo4j+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.