简体   繁体   English

通过REST API进行ArangoDB图形操作

[英]ArangoDB graph operations via REST API

Is it possible to use AQL query language via REST API to make graph queries? 是否可以通过REST API使用AQL查询语言进行图形查询?

Thanks. 谢谢。

Yes, HTTP Query cursor API is the right API to do this. 是的, HTTP Query游标API是执行此操作的正确API。 It allows executing AQL queries via HTTP. 它允许通过HTTP执行AQL查询。

Example (with a non-graph query): 示例(带有非图形查询):

curl        \
  -X POST   \
  --dump -  \
  "http://localhost:8529/_db/_system/_api/cursor" \
  --data '{"query":"FOR u IN users RETURN u","count":true}'

You can put your AQL query string (using graph functions) into the query attribute of the request. 您可以将AQL查询字符串(使用图形函数)放入请求的query属性中。 Bind parameters are optional. 绑定参数是可选的。 If used, they can be put into the optional bindVars attribute of the request: 如果使用它们,则可以将它们放入请求的可选bindVars属性中:

curl        \
  -X POST   \
  --dump -  \
  "http://localhost:8529/_db/_system/_api/cursor" \
  --data '{"query":"FOR u IN users FILTER u.name == @name RETURN u","bindVars":{"name":"foobar"}}'

Great! 大! But this AQL bellow works fine in the AQL editor, but not it the REST. 但是此AQL波纹管在AQL编辑器中工作正常,但在REST中却不能。

curl -X POST --dump - http://localhost:8529/_db/database/_api/cursor --data '{query:LET from = (FOR p IN products FILTER p.name == "p1" RETURN p._id) LET to=(FOR p IN products FILTER p.name == "p2" RETURN p._id) INSERT { _from: from[0], _to: to[0], type: "RELATED" } INTO productsedge}' HTTP/1.1 400 Bad Request Server: ArangoDB Connection: Keep-Alive Content-Type: application/json; curl -X POST --dump- http:// localhost:8529 / _db / database / _api / cursor --data'{query:LET from =(for p IN products FILTER p.name ==“ p1” RETURN p。 _id)LET to =(对于p IN产品,过滤器p.name ==“ p2”返回p._id)INSERT {_from:from [0],_to:to [0],键入:“ RELATED”} INTO productedge}' HTTP / 1.1 400错误的请求服务器:ArangoDB连接:Keep-Alive内容类型:application / json; charset=utf-8 Content-Length: 82 {"error":true,"errorMessage":"expecting attribute name","code":400,"errorNum":600} charset = utf-8内容长度:82 {“错误”:true,“ errorMessage”:“预期属性名称”,“代码”:400,“ errorNum”:600}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM