Neo4J查询

查询&写入

参数

model_1

<user_id>,<phone>, 双向关系

查询语法

查询结果

查询时间

1

写入

数据导入语句

 

USING PERIODIC COMMIT 10000 LOAD CSV WITH HEADERS FROM 'file:///data/neo4j_all.csv'   AS csvLine
create (n:contacts_userid{user_id:csvLine.user_id})

./neo4j-import --into /data/neo4j-community-3.3.1/data/databases/graph3.db   --nodes /data/neo4j-community-3.3.1/import/data/csv/movies.csv --nodes /data/neo4j-community-3.3.1/import/data/csv/actors.csv --relationships /data/neo4j-community-3.3.1/import/data/csv/roles.csv   --skip-bad-relationships=true --stacktrace --bad-tolerance=50000 --skip-duplicate-nodes=true

   

2

查询

         

3

 

有最多通讯录的用户(top10)

 

MATCH (k:Person)
RETURN k.uid, size((k)-[:H]->()) as degree
ORDER BY degree DESC limit 10;

"12546710", 1902

"19745018", 1222

359ms

/11ms

4

     

MATCH (k:Person)-[:H]->(m)
RETURN k.uid, count(m) as cnt
ORDER BY cnt DESC limit 10;

"12546710", 1902

"19745018", 1222

249ms

5

 

关联最多用户的电话(top10)

 

MATCH (m:M)
RETURN m.num, size(()-[:H]->(m)) as degree
ORDER BY degree DESC limit 10;

"4008308300", 116

"4008257119", 88

343ms

6

     

MATCH (m:M)
RETURN m.num, size((m)-[:Belong]->()) as degree
ORDER BY degree DESC limit 10;

"4008308300", 116

"4008257119", 88

329ms

7

     

MATCH (k)-[:H]->(m:M)
RETURN m.num, count(k) as cnt
ORDER BY cnt DESC limit 10;

"4008308300", 116

"4008257119", 88

1079ms

8

     

MATCH (m:M)<-[:H]-(k)
RETURN m.num, count(k) as cnt
ORDER BY cnt DESC limit 10;

"4008308300", 116

"4008257119", 88

851ms

9

     

MATCH (m:M)-[:Belong]->(k)
RETURN m.num, count(k) as cnt
ORDER BY cnt DESC limit 10;

 

845ms

10

     

MATCH (k)-[:H]->(m:M)
with m , count(k) as cnt
RETURN m.num, cnt
ORDER BY cnt DESC limit 10;

   

11

 

有通讯录重叠的用户,按重叠数量排序

user_id

MATCH (p1:Person {uid:"19722718"})-[:H]->(m)<-[:H]-(p2:Person)
return p2.uid, COUNT(*) AS cnt
order by cnt desc
limit 10

 

8ms

12

 

有通讯录重叠的用户,且重叠数量大于指定值的用户

(判定是否通讯录复制)

user_id,相同通讯录数量

MATCH (p1:Person {uid:"19722718"})-[:H]->(m)<-[:H]-(p2:Person)
with p2.uid as uid, count(*) as cnt
where cnt > 0
return cnt
order by cnt
limit 10;

 

8ms

13

LF/YH

通讯录风险电话数量

user_id

match(n:contacts_userid{user_id:'1111'})-[r:rel_all]->(n1:contacts_tel)<-[r1:rel_all]-(n2:contacts_userid) return n2.user_id,count(distinct n1.username)

   

14

LF/YH

有通讯录重叠的风险用户数

user_id, phone

match(n:contacts_userid{user_id:'1111'})-[r:rel_all]->(n1:contacts_tel)<-[r1:rel_all]-(n2:contacts_userid) return n2.user_id,count(distinct n1.username)

   

15

LF/YH

聚类_近90天密码相同人数

user_id

match(n:Person{uid:'19722718'}),(n1:Person) where n.password=n1.password and address_addtime>1512812891  return count(n1);

   

16

LF/YH

聚类_近90天密码相同的人中高风险拒绝人数

user_id

match(n:Person{uid:'19722718'}),(n1:Person) where n.password=n1.password and address_addtime>1512812891  return count(n1);

   

17

LF/YH

聚类_近90天密码相同的人中高风险拒绝人数占比

user_id

     

18

YH/LF

聚类_密码相同且ip相同人数

user_id

     

19

YH/LF

聚类_密码相同且ip相同的人中高风险拒绝人数

user_id

     

20

YH/LF

聚类_密码相同且单电相同人数

user_id

match(n:Person{uid:'19722718'}),(n1:Person) where n.password=n1.password and n.company_tel=n1.company_tel   return count(n1);

   

21

YH/LF

聚类_密码相同且单电相同的人中高风险拒绝人数

user_id

     

22

YZ/PP

聚类_密码相同且单名相同人数

user_id

match(n:Person{uid:'19722718'}),(n1:Person) where n.password=n1.password and n.company_name=n1.company_name   return count(n1);

   

23

YZ/PP

聚类_密码相同且单名相同的人中高风险拒绝人数

user_id

     

24

YZ/PP

聚类_密码相同且单址相同人数

user_id

match(n:Person{uid:'19722718'}),(n1:Person) where n.password=n1.password and n.company_address=n1.company_address  return count(n1);

   

25

YZ/PP

聚类_密码相同且单址前20位相同的人中高风险拒绝人数

user_id

     

26

YZ/PP

聚类_密码相同且家址相同人数

user_id

match(n:Person{uid:'19722718'}),(n1:Person) where n.password=n1.password and n.address=n1.address   return count(n1);

   

27

YZ/PP

聚类_密码相同且家址相同的人中高风险拒绝人数

user_id

     

28

PP/YZ

类_近90天内同设备同单名匹配人数

 

match(n:Person{uid:'19722718'}),(n1:Person) where n.password=n1.password and

n.register_device_id=n1.register_device_id

address_addtime>1512812891  return count(n1);

   

29

PP/YZ

聚类_近90天内同设备同单址匹配人数

 

match(n:Person{uid:'19722718'}),(n1:Person) where  n.company_name=n1.company_name and n.register_device_id=n1.register_device_id and address_addtime>1512812891  return count(n1);

   

30

PP/YZ

聚类_近90天内同设备同家址匹配人数

 

match(n:Person{uid:'19722718'}),(n1:Person) where 

n.address=n1.address and n.register_device_id=n1.register_device_id and address_addtime>1512812891  return count(n1);

   

31

PP/YZ

聚类_近90天内同设备且ip前7位相同匹配人数

 

match(n:Person{uid:'19722718'}),(n1:Person) where 

substring(n.address_addip)=substring(n1.address_addip) and n.register_device_id=n1.register_device_id and address_addtime>1512812891  return count(n1);

   

32

PP/YZ

聚类_近90天内同设备且lbs前2位相同匹配人数

       

 

注意:

neo4j 关于日期型的数据如何存储以及如何查? 目前好像只支持string,char,float,double 等类型转换,没有看到date型处理。

解决:把时间处理成了整型,如 19981022

您可以选择一种方式赞助本站