博客
关于我
Neo4j图数据库
阅读量:119 次
发布时间:2019-02-26

本文共 2052 字,大约阅读时间需要 6 分钟。

1.、数据导入

可以使用
LOAD CSV WITH HEADERS FROM “file:///Inventory.csv” AS row
MERGE (s:Store {name: row.store})
WITH *
MATCH (c:City {name: row.store})
MERGE (s)-[:IN_CITY]-©
WITH *
MATCH (p:Product {sku: row.sku})
MERGE §-[r:INVENTORY]->(s)
SET r.count = toInt(row.number)
RETURN *;

想用

call apoc.load.json("///reviews.json") YIELD value AS row
MATCH (c:Customer {customerid: toString(row.customerid)})
MATCH (p:Product {sku: toString(row.sku)})
MERGE ©-[r:REVIEWED]->§
SET r.rating = round(toFloat(row.review))
RETURN *;
必须先开启 apoc.import.file.enabled=true

社区发现

解析:
“CALL algo.unionFind(label:String, relationship:String, {weightProperty:‘weight’, threshold:0.42, defaultValue:1.0, write: true, partitionProperty:‘partition’}) YIELD nodes, setCount, loadMillis, computeMillis, writeMillis”
输入的为
label 节点类别;relationship 关系类别
可选输入
weightProperty 权重属性
threshold 边界值
defaultValue 默认值,当属性为空时的填充
返回
nodes 节点

CALL algo.unionFind.stream(‘User’, ‘FRIEND’, {weightProperty:‘weight’,

defaultValue:0.0, threshold:1.0, concurrency: 1})
YIELD nodeId,setId
RETURN algo.getNodeById(nodeId).id AS user, setId

threshold 门槛 边界

concurrency 并发性

删除全部数据

match (n) detach delete n

查看数据结构

call apoc.meta.graph == call db.schema()

with语句

使用with语句进行聚合过滤查询,示例:
MATCH (n {name:“John”})-[:friend]-(friend)
WITH n, count(friend) as friendsCount
WHERE friendsCount>3
RETURN n, friendsCount

使用with语句进行聚合更新,示例:

MATCH (n {name:‘John’})-[:friend]-(friend)
WITH n,count(friend) as friendsCount
SET n.friendsCount = friendsCount
RETURN n.friendsCount

//collect()将所有满足值聚集在一个列表中

match (p:Person)-[:ACTED_IN]->(m:Movie)
with p, count(*) as appearances, collect(m.title) as movies
where appearances > 1
return , appearances, movies

optinal match 类似于match ,不同之处在于 如果没有匹配到optinal match将用null作为未匹配到不分的值.

可以理解为mysql中的inner join 如果没有就用null.

查看数据库的图算法

CALL dbms.procedures() YIELD name, signature, description
WHERE name starts with “algo”
RETURN name, signature, description

查看APOC

CALL dbms.procedures() YIELD name, signature, description
WHERE name starts with “apoc”
RETURN name, signature, description

转载地址:http://wzru.baihongyu.com/

你可能感兴趣的文章
MySQL 是如何加锁的?
查看>>
MySQL 是怎样运行的 - InnoDB数据页结构
查看>>
mysql 更新子表_mysql 在update中实现子查询的方式
查看>>
MySQL 有什么优点?
查看>>
mysql 权限整理记录
查看>>
mysql 权限登录问题:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
查看>>
MYSQL 查看最大连接数和修改最大连接数
查看>>
MySQL 查看有哪些表
查看>>
mysql 查看锁_阿里/美团/字节面试官必问的Mysql锁机制,你真的明白吗
查看>>
MySql 查询以逗号分隔的字符串的方法(正则)
查看>>
MySQL 查询优化:提速查询效率的13大秘籍(避免使用SELECT 、分页查询的优化、合理使用连接、子查询的优化)(上)
查看>>
mysql 查询数据库所有表的字段信息
查看>>
【Java基础】什么是面向对象?
查看>>
mysql 查询,正数降序排序,负数升序排序
查看>>
MySQL 树形结构 根据指定节点 获取其下属的所有子节点(包含路径上的枝干节点和叶子节点)...
查看>>
mysql 死锁 Deadlock found when trying to get lock; try restarting transaction
查看>>
mysql 死锁(先delete 后insert)日志分析
查看>>
MySQL 死锁了,怎么办?
查看>>
MySQL 深度分页性能急剧下降,该如何优化?
查看>>
MySQL 深度分页性能急剧下降,该如何优化?
查看>>