• Neo4j基本操作


    CQL:

    create:创建节点,关系和属性
    match:检索有关节点,关系和属性数据
    return: 返回查询结果
    where:提供条件过滤检索数据
    delete: 删除节点和关系的属性
    order by :排序检索数据
    set :添加或更新标签
    peoperties 属性
    
    节点:()
    关系:[ ]
     

    通过文件创建关系:

    load csv from "file:///data.csv" as line
    create (:HLRelation{from:line[1],relation:line[3],to:line[0]})
     

    通过文件创建结点:

    load csv from "file:///data.csv" as line
    create (:person2{name:line[0]})
     

    创建图谱:

    match(n:p1),(m:HLRelation),(s:p2) where m.from=n.name and m.to=s.name
    create (n)-[:HL关系{relation:m.relation}]->(s)
    return n.name,m.relation,s.name
     

    处理结点重复问题:

    找到重复的数据
    match (n:Location) return count(n); # 13
    match (n:Location) return count(distinct n.city); # 5 说明有6个是重复的
    # 查看重复的id
    match (n:Location), (m:Location) where n.city = m.city and id(n) <> id(m) return n,id(n), m, id(m); 
    
    删除该id所在的关系
    match (n:en5)-[r:Relation]->(m:en5) where id(m)=6 delete r;
    
    删除该id
    match (n:Location) where id(n)=6 delete n;
    match (n:Location) where id(n) in [62,63,82] delete n;
    
    检查
    match (n:Location) return count(n); # 5
    match (n:Location) return count(distinct n.city); # 5 说明没有重复的了
    
     

    中医药数据集暂时不公开,可以用开源数据集代替:http://www.openkg.cn/group/medicine

  • 相关阅读:
    Spark数据读取
    05、TypeScript 中的泛型
    04、TypeScript 中的接口
    03、TypeScript 中的类
    02、TypeScript 中的函数
    01、TypeScript 数据类型
    Vue-router 知识点
    什么是跨域?如何解决跨域问题
    工作中积累的问题、知识点总结100题(0-20)
    封装一个 Promise 对象。了解其原理
  • 原文地址:https://www.cnblogs.com/dreamzj/p/16315946.html
Copyright © 2020-2023  润新知