本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
亚马逊 Neptune 终端节点 openCypher HTTPS
openCypher 在HTTPS端点上读取和写入查询
终 openCypher HTTPS端节点支持同时使用和POST
方法进行读取GET
和更新查询。不支持 DELETE
和 PUT
方法。
以下说明将引导您使用curl
命令和连接到 openCypher 终端节点HTTPS。您必须在 Neptune 数据库EC2实例所在的虚拟私有云 (VPC) 中的 Amazon 实例中按照这些说明进行操作。
语法如下:
HTTPS://
(the server)
:(the port number)
/openCypher
以下是示例读取查询,一个使用 POST
,一个使用 GET
:
1. 使用 POST
:
curl HTTPS://
server
:port
/openCypher \ -d "query=MATCH (n1) RETURN n1;"
2. 使用GET
(查询字符串采用 URL-编码):
curl -X GET \ "HTTPS://
server
:port
/openCypher?query=MATCH%20(n1)%20RETURN%20n1"
以下是示例写入/更新查询,一个使用 POST
,一个使用 GET
:
1. 使用 POST
:
curl HTTPS://
server
:port
/openCypher \ -d "query=CREATE (n:Person { age: 25 })"
2. 使用GET
(查询字符串采用 URL-编码):
curl -X GET \ "HTTPS://
server
:port
/openCypher?query=CREATE%20(n%3APerson%20%7B%20age%3A%2025%20%7D)"
默认 openCypher JSON结果格式
默认情况下,或将请求标头显式设置为,则返回以下JSON格式Accept: application/json
。这种格式旨在使用大多数库的原生语言特征轻松解析为对象。
返回的JSON文档包含一个字段results
,其中包含查询返回值。以下示例显示了常用值的JSON格式。
值响应示例:
{ "results": [ { "count(a)": 121 } ] }
节点响应示例:
{ "results": [ { "a": { "~id": "22", "~entityType": "node", "~labels": [ "airport" ], "~properties": { "desc": "Seattle-Tacoma", "lon": -122.30899810791, "runways": 3, "type": "airport", "country": "US", "region": "US-WA", "lat": 47.4490013122559, "elev": 432, "city": "Seattle", "icao": "KSEA", "code": "SEA", "longest": 11901 } } } ] }
关系响应示例:
{ "results": [ { "r": { "~id": "7389", "~entityType": "relationship", "~start": "22", "~end": "151", "~type": "route", "~properties": { "dist": 956 } } } ] }
路径响应示例:
{ "results": [ { "p": [ { "~id": "22", "~entityType": "node", "~labels": [ "airport" ], "~properties": { "desc": "Seattle-Tacoma", "lon": -122.30899810791, "runways": 3, "type": "airport", "country": "US", "region": "US-WA", "lat": 47.4490013122559, "elev": 432, "city": "Seattle", "icao": "KSEA", "code": "SEA", "longest": 11901 } }, { "~id": "7389", "~entityType": "relationship", "~start": "22", "~end": "151", "~type": "route", "~properties": { "dist": 956 } }, { "~id": "151", "~entityType": "node", "~labels": [ "airport" ], "~properties": { "desc": "Ontario International Airport", "lon": -117.600997924805, "runways": 2, "type": "airport", "country": "US", "region": "US-CA", "lat": 34.0559997558594, "elev": 944, "city": "Ontario", "icao": "KONT", "code": "ONT", "longest": 12198 } } ] } ] }