In neo4j can I get a less verbose REST api response

梦想的初衷 提交于 2020-01-14 14:15:51

问题


  1. Is there a way I can get a less verbose rest api response in neo4j, perhaps something with just the node data? It seems like it's a bit of a waste of bandwidth to send all that extra data on every request.

  2. Why is all that metadata included in the response anyways? For instance, the base api url is repeated throughout, and once you have the node id, one can reliably predict the urls for all the properties like self, properties, relationships, etc... They don't seem like terribly volatile urls.


{
      "extensions" : {
      },
      "paged_traverse" : "http://localhost:7474/db/data/node/183/paged/traverse/{returnType}{?pageSize,leaseTime}",
      "outgoing_relationships" : "http://localhost:7474/db/data/node/183/relationships/out",
      "traverse" : "http://localhost:7474/db/data/node/183/traverse/{returnType}",
      "all_typed_relationships" : "http://localhost:7474/db/data/node/183/relationships/all/{-list|&|types}",
      "all_relationships" : "http://localhost:7474/db/data/node/183/relationships/all",
      "property" : "http://localhost:7474/db/data/node/183/properties/{key}",
      "self" : "http://localhost:7474/db/data/node/183",
      "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/183/relationships/out/{-list|&|types}",
      "properties" : "http://localhost:7474/db/data/node/183/properties",
      "incoming_relationships" : "http://localhost:7474/db/data/node/183/relationships/in",
      "incoming_typed_relationships" : "http://localhost:7474/db/data/node/183/relationships/in/{-list|&|types}",
      "create_relationship" : "http://localhost:7474/db/data/node/183/relationships",
      "data" : {
      }
    }

回答1:


The information sent is part of the REST discovery mechanism built into the HTTP API. Changing this would render a lot of existing client software broken as those values are used as a replacement for "educated guesswork".

The existing server provides no way to not produce this data but if its simply node properties that you are after, the http://localhost:7474/db/data/node/183/properties URI will just provide you that simple set of key-value pairs.

It is true that the URIs themselves do not appear to be particularly volatile. However, if these URIs were to change in a future server version, client software which had adhered to the discovery mechanism would be protected from that change.




回答2:


You could always write your own server plugin which serves data in the format you want.




回答3:


If you use Cypher, you can trim down the amount of verbosity by just returning not full nodes/rels, but values on these that you need, see http://docs.neo4j.org/chunked/snapshot/rest-api-cypher.html




回答4:


I ran across this unanswered question when I was looking for the same thing, so I know I might help someone out by plugging my solution to this problem. Trying to interpret the Node-Neo4j API



来源:https://stackoverflow.com/questions/14092613/in-neo4j-can-i-get-a-less-verbose-rest-api-response

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!