Closed liuxiaocs7 closed 1 year ago
Fix this page: https://hugegraph.apache.org/cn/docs/clients/restful-api/vertex/
Local Tests:
Env: HG-Server depolyed by docker, (ip:port, 192.168.34.164:18080)
docker
192.168.34.164:18080
schema:
schema.propertyKey("name").asText().ifNotExist().create(); schema.propertyKey("age").asInt().ifNotExist().create(); schema.propertyKey("city").asText().ifNotExist().create(); schema.propertyKey("weight").asDouble().ifNotExist().create(); schema.propertyKey("lang").asText().ifNotExist().create(); schema.propertyKey("price").asDouble().ifNotExist().create(); schema.propertyKey("hobby").asText().valueList().ifNotExist().create(); schema.vertexLabel("person").properties("name", "age", "city", "weight", "hobby").primaryKeys("name").nullableKeys("age", "city", "weight", "hobby").ifNotExist().create(); schema.vertexLabel("software").properties("name", "lang", "price").primaryKeys("name").nullableKeys("lang", "price").ifNotExist().create(); schema.indexLabel("personByAge").onV("person").by("age").range().ifNotExist().create();
curl -i -H "Content-Type: application/json" -d '{"label":"person","properties":{"name":"marko","age":29}}' http://192.168.34.164:18080/graphs/hugegraph/graph/vertices
response:
curl -i -H "Content-Type: application/json" -d '{"label":"person","properties":{"name":"marko","age":29}}' http://192.168.34.164:18080/graphs/hugegraph/graph/vertices HTTP/1.1 201 Created Content-Length: 88 Connection: keep-alive Content-Type: application/json;charset=UTF-8 Keep-Alive: timeout=4 Proxy-Connection: keep-alive {"id":"1:marko","label":"person","type":"vertex","properties":{"name":"marko","age":29}}
curl -i -H "Content-Type: application/json" -d '[{"label":"person","properties":{"name":"marko","age":29}},{"label":"software","properties":{"name":"ripple","lang":"java","price":199}}]' http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/batch
curl -i -H "Content-Type: application/json" -d '[{"label":"person","properties":{"name":"marko","age":29}},{"label":"software","properties":{"name":"ripple","lang":"java","price":199}}]' http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/batch HTTP/1.1 201 Created Content-Length: 22 Connection: keep-alive Content-Type: application/json;charset=UTF-8 Keep-Alive: timeout=4 Proxy-Connection: keep-alive ["1:marko","2:ripple"]
curl -i -X PUT -H "Content-Type: application/json" -d '{"label":"person","properties":{"age":30,"city":"Beijing"}}' http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/\"1:marko\"?action=append
curl -i -X PUT -H "Content-Type: application/json" -d '{"label":"person","properties":{"age":30,"city":"Beijing"}}' http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/\"1:marko\"?action=append HTTP/1.1 200 OK Content-Length: 105 Connection: keep-alive Content-Type: application/json;charset=UTF-8 Keep-Alive: timeout=4 Proxy-Connection: keep-alive {"id":"1:marko","label":"person","type":"vertex","properties":{"name":"marko","age":30,"city":"Beijing"}}
add some verticesfor test:
curl -i -H "Content-Type: application/json" -d '[{"label":"person","properties":{"name":"josh","age":32,"city":"Beijing","weight":0.1,"hobby":["reading","football"]}},{"label":"software","properties":{"name":"lop","lang":"java","price":328}}]' http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/batch
curl -i -H "Content-Type: application/json" -d '[{"label":"person","properties":{"name":"josh","age":32,"city":"Beijing","weight":0.1,"hobby":["reading","football"]}},{"label":"software","properties":{"name":"lop","lang":"java","price":328}}]' http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/batch HTTP/1.1 201 Created Content-Length: 18 Connection: keep-alive Content-Type: application/json;charset=UTF-8 Keep-Alive: timeout=4 Proxy-Connection: keep-alive ["1:josn","2:lop"]
Batch Update Vertex Properties results:
curl -i -X PUT -H "Content-Type: application/json" -d '{"vertices":[{"label":"software","type":"vertex","properties":{"name":"lop","lang":"c++","price":299}},{"label":"person","type":"vertex","properties":{"name":"josh","city":"Shanghai","weight":0.2,"hobby":["swiming"]}}],"update_strategies":{"price":"BIGGER","age":"OVERRIDE","city":"OVERRIDE","weight":"SUM","hobby":"UNION"},"create_if_not_exist":true}' http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/batch
curl -i -X PUT -H "Content-Type: application/json" -d '{"vertices":[{"label":"software","type":"vertex","properties":{"name":"lop","lang":"c++","price":299}},{"label":"person","type":"vertex","properties":{"name":"josh","city":"Shanghai","weight":0.2,"hobby":["swiming"]}}],"update_strategies":{"price":"BIGGER","age":"OVERRIDE","city":"OVERRIDE","weight":"SUM","hobby":"UNION"},"create_if_not_exist":true}' http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/batchaph/vertices/batch HTTP/1.1 200 OK Content-Length: 278 Connection: keep-alive Content-Type: application/json;charset=UTF-8 Keep-Alive: timeout=4 Proxy-Connection: keep-alive {"vertices":[{"id":"2:lop","label":"software","type":"vertex","properties":{"name":"lop","lang":"c++","price":328.0}},{"id":"1:josh","label":"person","type":"vertex","properties":{"name":"josh","age":32,"city":"Shanghai","weight":0.3,"hobby":["reading","football","swiming"]}}]}
curl -i -X PUT -H "Content-Type: application/json" -d '{"label":"person","properties":{"city":"Beijing"}}' http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/\"1:marko\"?action=eliminate
curl -i -X PUT -H "Content-Type: application/json" -d '{"label":"person","properties":{"city":"Beijing"}}' http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/\"1:marko\"?action=eliminate HTTP/1.1 200 OK Content-Length: 88 Connection: keep-alive Content-Type: application/json;charset=UTF-8 Keep-Alive: timeout=4 Proxy-Connection: keep-alive {"id":"1:marko","label":"person","type":"vertex","properties":{"name":"marko","age":30}}
curl -i 'http://192.168.34.164:18080/graphs/hugegraph/graph/vertices?label=person&properties=\{%22age%22:30\}&limit=1' \ --compressed
HTTP/1.1 200 OK Content-Length: 103 Connection: keep-alive Content-Encoding: gzip Content-Type: application/json;charset=UTF-8 Keep-Alive: timeout=4 Proxy-Connection: keep-alive {"vertices":[{"id":"1:marko","label":"person","type":"vertex","properties":{"name":"marko","age":30}}]}
curl -i -H "Content-Type: application/json" -d '[{"label":"person","properties":{"name":"peter","age":29,"city":"Shanghai"}},{"label":"person","properties":{"name":"vadas","age":27,"city":"Hongkong"}}]' http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/batch
curl -i -H "Content-Type: application/json" -d '[{"label":"person","properties":{"name":"peter","age":29,"city":"Shanghai"}},{"label":"person","properties":{"name":"vadas","age":27,"city":"Hongkong"}}]' http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/batch HTTP/1.1 201 Created Content-Length: 21 Connection: keep-alive Content-Type: application/json;charset=UTF-8 Keep-Alive: timeout=4 Proxy-Connection: keep-alive ["1:peter","1:vadas"]
Start paging query
curl -i 'http://192.168.34.164:18080/graphs/hugegraph/graph/vertices?page&limit=3' \ --compressed
curl -i 'http://192.168.34.164:18080/graphs/hugegraph/graph/vertices?page&limit=3' \ --compressed HTTP/1.1 200 OK Content-Length: 227 Connection: keep-alive Content-Encoding: gzip Content-Type: application/json;charset=UTF-8 Keep-Alive: timeout=4 Proxy-Connection: keep-alive {"vertices":[{"id":"2:lop","label":"software","type":"vertex","properties":{"name":"lop","lang":"c++","price":328.0}},{"id":"1:josh","label":"person","type":"vertex","properties":{"name":"josh","age":32,"city":"Shanghai","weight":0.3,"hobby":["reading","football","swiming"]}},{"id":"1:marko","label":"person","type":"vertex","properties":{"name":"marko","age":30}}],"page": "CIYxOnBldGVyAAAAAAAAAAM="}
search next page results:
curl -i 'http://192.168.34.164:18080/graphs/hugegraph/graph/vertices?page=CIYxOnBldGVyAAAAAAAAAAM=&limit=3' \ --compressed
curl -i 'http://192.168.34.164:18080/graphs/hugegraph/graph/vertices?page=CIYxOnBldGVyAAAAAAAAAAM=&limit=3' \ --compressed HTTP/1.1 200 OK Content-Length: 186 Connection: keep-alive Content-Encoding: gzip Content-Type: application/json;charset=UTF-8 Keep-Alive: timeout=4 Proxy-Connection: keep-alive {"vertices":[{"id":"1:peter","label":"person","type":"vertex","properties":{"name":"peter","age":29,"city":"Shanghai"}},{"id":"1:vadas","label":"person","type":"vertex","properties":{"name":"vadas","age":27,"city":"Hongkong"}},{"id":"2:ripple","label":"software","type":"vertex","properties":{"name":"ripple","lang":"java","price":199.0}}],"page": null}
curl -i 'http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/%221:marko%22'
curl -i 'http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/%221:marko%22' HTTP/1.1 200 OK Content-Length: 88 Connection: keep-alive Content-Type: application/json;charset=UTF-8 Keep-Alive: timeout=4 Proxy-Connection: keep-alive {"id":"1:marko","label":"person","type":"vertex","properties":{"name":"marko","age":30}}
curl -i -X DELETE 'http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/%221:marko%22'
curl -i -X DELETE 'http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/%221:marko%22' HTTP/1.1 204 No Content Connection: keep-alive Keep-Alive: timeout=4 Proxy-Connection: keep-alive
curl -i -X DELETE 'http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/%221:marko%22?label=person'
curl -i -X DELETE 'http://192.168.34.164:18080/graphs/hugegraph/graph/vertices/%221:marko%22?label=person' HTTP/1.1 204 No Content Connection: keep-alive Keep-Alive: timeout=4 Proxy-Connection: keep-alive
Fix this page: https://hugegraph.apache.org/cn/docs/clients/restful-api/vertex/
Local Tests:
Env: HG-Server depolyed by
docker
, (ip:port,192.168.34.164:18080
)schema:
1 Create a vertex
response:
2 Create multiple vertices
response:
3 Update vertex properties
response:
4 Batch Update Vertex Properties
add some verticesfor test:
response:
Batch Update Vertex Properties results:
response:
5 Delete Vertex Properties
response:
6 Get Vertices that Meet the Criteria
response:
Paginate through all vertices, retrieve the first page (page without parameter value), limited to 3 records
add some verticesfor test:
response:
Start paging query
response:
search next page results:
response:
7 Retrieve Vertex by ID
response:
Delete the vertex based on ID only.
response:
Delete Vertex by Label+ID
response: