java neo4j rest api_Neo4j REST API使用教程
下载解压:
$ tar xfz neo4j-community-1.4.M04-unix.tar.gz
$ rm neo4j-community-1.4.M04-unix.tar.gz
$ cd neo4j-community-1.4.M04/
启动Neo4j
#可以按需要修改配置文件
$ nano conf/neo4j-server.properties
#启动
$ ./bin/neo4j start
Starting Neo4j Server...
Waiting for Neo4j Server.....
7/4/11 7:07:13 PM org.neo4j.server.database.Database INFO: Using database at NEO4J/neo4j-community-1.4.M04/data/graph.db
7/4/11 7:07:13 PM org.neo4j.server.modules.DiscoveryModule INFO: Mounted discovery module at [/]
Adding JAXRS packages [org.neo4j.server.rest.discovery] at [/]
Adding JAXRS packages [org.neo4j.server.rest.web] at [/db/data]
Adding JAXRS packages [org.neo4j.server.webadmin.rest] at [/db/manage]
7/4/11 7:07:13 PM org.neo4j.server.modules.RESTApiModule INFO: Mounted REST API at [/db/data/]
7/4/11 7:07:13 PM org.neo4j.server.modules.ManagementApiModule INFO: Mounted management API at [/db/manage/]
7/4/11 7:07:13 PM org.neo4j.server.modules.WebAdminModule INFO: Mounted webadmin at [/webadmin]
7/4/11 7:07:13 PM org.neo4j.server.NeoServerWithEmbeddedWebServer INFO: Starting Neo Server on port [7474]
7/4/11 7:07:13 PM org.neo4j.server.web.Jetty6WebServer INFO: Mounting static content at [/webadmin] from [webadmin-html]
7/4/11 7:07:15 PM org.neo4j.server.NeoServerWithEmbeddedWebServer INFO: Server started on [http://okazaki:7474/]
running: PID:2816
访问根目录
$ curl -D - -H Accept:application/json "http://localhost:7474/db/data/"
HTTP/1.1 200 OK
Content-Length: 410
Content-Encoding: UTF-8
Content-Type: application/json
Access-Control-Allow-Origin: *
Server: Jetty(6.1.25)
{
"relationship_index" : "http://localhost:7474/db/data/index/relationship",
"node" : "http://localhost:7474/db/data/node",
"relationship_types" : "http://localhost:7474/db/data/relationship/types",
"extensions_info" : "http://localhost:7474/db/data/ext",
"node_index" : "http://localhost:7474/db/data/index/node",
"reference_node" : "http://localhost:7474/db/data/node/0",
"extensions" : {
}
创建一个数据节点:
$ curl -D - -H Accept:application/json -X POST http://localhost:7474/db/data/node
HTTP/1.1 201 Created
Content-Length: 968
Location: http://localhost:7474/db/data/node/2
Content-Encoding: UTF-8
Content-Type: application/json
Access-Control-Allow-Origin: *
Server: Jetty(6.1.25)
{
"outgoing_relationships" : "http://localhost:7474/db/data/node/2/relationships/out",
(...)
设置节点的各种属性:
$ curl -D - -H Content-Type:application/json -X PUT \
-d '{"name":"Charles Darwin","birthDate":"1809-02-12","deathDate":"1882-04-19","knownFor":["Voyage of the Beagle","On the Origin of Species evolution by natural selection"]}' \
http://localhost:7474/db/data/node/2/properties
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Server: Jetty(6.1.25)
查看设置好的节点信息:
$ curl -D - -H Accept:application/json http://localhost:7474/db/data/node/2HTTP/1.1 200 OK
Content-Length: 1166
Content-Encoding: UTF-8
Content-Type: application/json
Access-Control-Allow-Origin: *
Server: Jetty(6.1.25)
{
"outgoing_relationships" : "http://localhost:7474/db/data/node/2/relationships/out",
"data" : {
"knownFor" : [ "Voyage of the Beagle", "On the Origin of Species evolution by natural selection" ],
"name" : "Charles Darwin",
"birthDate" : "1809-02-12",
"deathDate" : "1882-04-19"
},
"traverse" : "http://localhost:7474/db/data/node/2/traverse/{returnType}",
"all_typed_relationships" : "http://localhost:7474/db/data/node/2/relationships/all/{-list|&|types}",
"property" : "http://localhost:7474/db/data/node/2/properties/{key}",
"self" : "http://localhost:7474/db/data/node/2",
"properties" : "http://localhost:7474/db/data/node/2/properties",
"outgoing_typed_relationships" : "http://localhost:7474/db/data/node/2/relationships/out/{-list|&|types}",
"incoming_relationships" : "http://localhost:7474/db/data/node/2/relationships/in",
"extensions" : {
},
"create_relationship" : "http://localhost:7474/db/data/node/2/relationships",
"all_relationships" : "http://localhost:7474/db/data/node/2/relationships/all",
"incoming_typed_relationships" : "http://localhost:7474/db/data/node/2/relationships/in/{-list|&|types}"
}
仅查看节点属性:
$ curl -H Accept:application/json http://localhost:7474/db/data/node/2/properties
{
"knownFor" : [ "Voyage of the Beagle", "On the Origin of Species evolution by natural selection" ],
"name" : "Charles Darwin",
"birthDate" : "1809-02-12",
"deathDate" : "1882-04-19"
}
将创建节点和设置属性合到一步进行:
$ curl -D - -H Accept:application/json -H Content-Type:application/json -X POST -d '{"name":"Alfred Russel Wallace","birthDate":"1823-01-08","deathDate":"1913-11-07","knownFor":["natural selection","biogeography"]}' "http://localhost:7474/db/data/node"
HTTP/1.1 201 Created
Content-Length: 1127
Location: http://localhost:7474/db/data/node/3
Content-Encoding: UTF-8
Content-Type: application/json
Access-Control-Allow-Origin: *
Server: Jetty(6.1.25)
{
"outgoing_relationships" : "http://localhost:7474/db/data/node/3/relationships/out",
"data" : {
"knownFor" : [ "natural selection", "biogeography" ],
"name" : "Alfred Russel Wallace",
"birthDate" : "1823-01-08",
"deathDate" : "1913-11-07"
},
"traverse" : "http://localhost:7474/db/data/node/3/traverse/{returnType}",
(...)
}
设置某一个属性:
$ curl D - -H Accept:application/json -H Content-Type:application/json -X PUT \
-d '"United Kingdom"' \
"http://localhost:7474/db/data/node/3/properties/citizenship"
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Server: Jetty(6.1.25)
$ curl -H Accept:application/json http://localhost:7474/db/data/node/3/properties{
"knownFor" : [ "natural selection", "biogeography" ],
"name" : "Alfred Russel Wallace",
"citizenship" : "United Kingdom",
"birthDate" : "1823-01-08",
"deathDate" : "1913-11-07"
}
删除节点:
$ curl -D - -H Accept:application/json -X POST http://localhost:7474/db/data/node
HTTP/1.1 201 Created
Content-Length: 968
Location: http://localhost:7474/db/data/node/4
Content-Encoding: UTF-8
Content-Type: application/json
Access-Control-Allow-Origin: *
Server: Jetty(6.1.25)
$ curl -D - -X DELETE http://localhost:7474/db/data/node/4
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Server: Jetty(6.1.25)
创建一个Darwin认识Wallace的关系:
$ curl -D - -H Accept:application/json -H Content-Type:application/json -X POST -d '{"type":"KNOWS","to":"http://localhost:7474/db/data/node/3","data":{"ref":"http://en.wikipedia.org/wiki/Charles_Darwin"}}' "http://localhost:7474/db/data/node/2/relationships"
HTTP/1.1 201 Created
Content-Length: 439
Location: http://localhost:7474/db/data/relationship/0
Content-Encoding: UTF-8
Content-Type: application/json
Access-Control-Allow-Origin: *
Server: Jetty(6.1.25)
{
"start" : "http://localhost:7474/db/data/node/2",
"data" : {
"ref" : "http://en.wikipedia.org/wiki/Charles_Darwin"
},
"self" : "http://localhost:7474/db/data/relationship/0",
"property" : "http://localhost:7474/db/data/relationship/0/properties/{key}",
"properties" : "http://localhost:7474/db/data/relationship/0/properties",
"type" : "KNOWS",
"extensions" : {
},
"end" : "http://localhost:7474/db/data/node/3"
}
#获取这个关系的相关信息
$ curl -H Content-Type:application/json "http://localhost:7474/db/data/relationship/0/properties"
{
"ref" : "http://en.wikipedia.org/wiki/Charles_Darwin"
}
为这个关系设置属性:
$ curl -D - -H Content-Type:application/json -X PUT -d '"Darwin received a letter from Wallace asking if the book would examine human origins"' "http://localhost:7474/db/data/relationship/0/properties/comment"
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Server: Jetty(6.1.25)
$ curl -H Content-Type:application/json "http://localhost:7474/db/data/relationship/0/properties"
{
"ref" : "http://en.wikipedia.org/wiki/Charles_Darwin",
"comment" : "Darwin received a letter from Wallace asking if the book would examine human origins"
}
获取关系类型列表:
$ curl -H Content-Type:application/json "http://localhost:7474/db/data/relationship/types"
["KNOWS"]
获取关系列表:
#from Darwin
$ curl -H Content-Type:application/json "http://localhost:7474/db/data/node/2/relationships/out/KNOWS"
[ {
"start" : "http://localhost:7474/db/data/node/2",
"data" : {
"ref" : "http://en.wikipedia.org/wiki/Charles_Darwin",
"comment" : "Darwin received a letter from Wallace asking if the book would examine human origins"
},
"self" : "http://localhost:7474/db/data/relationship/0",
"property" : "http://localhost:7474/db/data/relationship/0/properties/{key}",
"properties" : "http://localhost:7474/db/data/relationship/0/properties",
"type" : "KNOWS",
"extensions" : {
},
"end" : "http://localhost:7474/db/data/node/3"
} ]
#in to Darwin
$ curl -H Content-Type:application/json "http://localhost:7474/db/data/node/2/relationships/in/KNOWS"
[ ]
#out from wallace
$ curl -H Content-Type:application/json "http://localhost:7474/db/data/node/3/relationships/out/KNOWS"
[ ]
#all from/to wallace
$ curl -H Content-Type:application/json "http://localhost:7474/db/data/node/3/relationships/all/KNOWS"
[ {
"start" : "http://localhost:7474/db/data/node/2",
"data" : {
"ref" : "http://en.wikipedia.org/wiki/Charles_Darwin",
"comment" : "Darwin received a letter from Wallace asking if the book would examine human origins"
},
"self" : "http://localhost:7474/db/data/relationship/0",
"property" : "http://localhost:7474/db/data/relationship/0/properties/{key}",
"properties" : "http://localhost:7474/db/data/relationship/0/properties",
"type" : "KNOWS",
"extensions" : {
},
"end" : "http://localhost:7474/db/data/node/3"
} ]
shutdown服务器:
$ ./bin/neo4j stop
Stopping Neo4j Server...
7/4/11 7:09:30 PM org.neo4j.server.NeoServerBootstrapper INFO: Neo4j Server shutdown initiated by kill signal
7/4/11 7:09:30 PM org.neo4j.server.NeoServerWithEmbeddedWebServer INFO: Successfully shutdown Neo Server on port [7474]
Waiting for Neo4j Server to exit...
Stopped Neo4j Server.
java neo4j rest api_Neo4j REST API使用教程相关推荐
- java neo4j rest api_Neo4j REST API使用实例—ttlsa教程系列之neo4j(二)
ttlsa教程系列之neo4j---(二)Neo4j REST API使用实例 一. 简介 通过REST API方式与Neo4j进行交互式操作.请求和响应数据默认是以JSON格式展示的.需要显示设置请 ...
- Java技术:Mybatis-plus常用API全套教程,值得收藏!
前言 官网: https://baomidou.com/ 创建数据库 数据库名为mybatis_plus 创建表 创建user表 DROP TABLE IF EXISTS user; CREATE T ...
- Windows下Libvirt Java API使用教程(二)- 接口使用说明
介绍完libvirt Java API的部署工作: <Windows下Libvirt Java API使用教程(一)- 开发环境部署> 接下来我们就介绍一下接口的使用和代码样例. libv ...
- Windows下Libvirt Java API使用教程(三)- TLS认证访问和动态链接文件依赖
之前已经介绍过了libvirt api的上手使用方式: <Windows下Libvirt Java API使用教程(二)- 接口使用说明> <Windows下Libvirt Java ...
- Java官方相关资源文件的获取教程
Java官方相关资源文件的获取教程 说明 类库源文件的获取 JDK文档的下载 阅读联机API文档 Java语言和虚拟机规范:Java Language and Virtual Machine Spec ...
- Java SE 9:Stream API的改进
发表简要目录: (Post Brief Table of Content:) Introduction介绍 Java SE 8: Stream API BasicsJava SE 8:Stream A ...
- java反射用法示例_Java反射示例教程
java反射用法示例 Java Reflection provides ability to inspect and modify the runtime behavior of applicatio ...
- 从申请到调用:全国快递物流查询 API 使用教程
引言 面对越来越多的快递需求和快递公司的日益增多,手动查询快递状态的工作变得愈发繁琐.此时,一个全国快递物流查询 API 的出现能够极大地提高查询的效率和准确性,解决人工查询的问题,为用户提供更加便捷 ...
- Java实现短信验证码--(完整教程)
原 Java实现短信验证码--(完整教程) 2018年04月24日 13:03:12 北山_ 阅读数 19189更多 分类专栏: Java 阿里云 版权声明:本文为博主原创文章,遵循 CC 4.0 B ...
最新文章
- POJ-2391 Ombrophobic Bovines 网络流-拆点构图
- Tungsten Fabric SDN — VNC API — API Client 的 Python SDK
- 【原创】Struts2.5.12版本中使用通配符*
- 理解 pkg-config 工具
- python有强大吗_python有多强大
- Centos 设置zookeeper开机自启动
- 浏览器接收响应数据过大_DOM总结:数据通信(HTTP协议和Ajax)
- 硫辛酸的7種功效及副作用(10點使用禁忌要留意)
- ThreadLocal和线程同步机制的对比
- .NET环境下水晶报表使用总
- 在mysql中REGEXP_在MySQL中使用RegExp中的列
- 王思聪欠款1.5亿成被执行人 孙宇晨:我帮你还钱!
- FTP服务器的搭建及创建虚拟用户进行认证访问
- Linux之diff命令
- 京东下拉词框天猫下拉词框优化推广方法分享
- 线程学习9——Mutex类
- 用自己数据集训练Mask_RCNN代码
- 二维码的纠错码原理及细节
- Azure设计模式之管道过滤器模式
- 什么是UPS UPS的选购技巧介绍
热门文章
- sudo: /etc/sudoers is world writable 错误解决方案
- arm板telnetd为什么运行不了_Win10 ARM 迎来原生 PS,微软玩 ARM 能赢过苹果吗
- c++图形中如何判断鼠标点击在一条直线上_PS教程:十种抠图方法【上】
- mysql安装到最后报错_mysql 安装到最后一步时,start service 为失败状态
- java 浏览器 安全设置_IE浏览器安全设置脚本
- mysql 主机 %_MySQL 开启远程链接(localhost 以外的主机)
- java 如何让HashMap变成线程安全的
- 济南职业学院计算机信息管理在哪个校区,计算机学院圆满完成省计算机信息管理专业教学指导方案开发...
- c语言大学程序设计题库,黑龙江大学C语言程序设计试题库程序单选
- 的g极串一个电阻_Ohm#39;s Law 简单系列D:从惠斯通(会石头)测电阻开始说