Amazon Neptune openCypher HTTPS 端點 - Amazon Neptune

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

Amazon Neptune openCypher HTTPS 端點

openCypher 讀取和寫入HTTPS端點上的查詢

端點支援使用 openCypher HTTPS和 POST方法讀取GET和更新查詢。不支援 DELETEPUT 方法。

下列指示會逐步引導您使用 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 } } ] } ] }