The response returned by Neo4j's REST interfaces are very verbose - they return not only the data in each node requested, but also the full discoverability for every node requested. If I just want some node data, the results are about 20 times bigger than I actually need, and I run into problems with out-of-memory exceptions and the like.
For example, a request for a node might return the following:
{
"labels" : "http://giuncwy02:7475/db/data/node/67/labels",
"outgoing_relationships" : "http://giuncwy02:7475/db/data/node/67/relationships/out",
"data" : {
"id" : "908754897618956",
"currentStatus" : "Active",
},
"traverse" : "http://giuncwy02:7475/db/data/node/67/traverse/{returnType}",
"all_typed_relationships" : "http://giuncwy02:7475/db/data/node/67/relationships/all/{-list|&|types}",
"self" : "http://giuncwy02:7475/db/data/node/67",
"property" : "http://giuncwy02:7475/db/data/node/67/properties/{key}",
"outgoing_typed_relationships" : "http://giuncwy02:7475/db/data/node/67/relationships/out/{-list|&|types}",
"properties" : "http://giuncwy02:7475/db/data/node/67/properties",
"incoming_relationships" : "http://giuncwy02:7475/db/data/node/67/relationships/in",
"extensions" : { },
"create_relationship" : "http://giuncwy02:7475/db/data/node/67/relationships",
"paged_traverse" : "http://giuncwy02:7475/db/data/node/67/paged/traverse/{returnType}{?pageSize,leaseTime}",
"all_relationships" : "http://giuncwy02:7475/db/data/node/67/relationships/all",
"incoming_typed_relationships" : "http://giuncwy02:7475/db/data/node/67/relationships/in/{-list|&|types}",
"metadata" : {
"id" : 67,
"labels" : [ "Substation" ]
}
}
Is there a way to reduce the amount of information returned in the response? All I really want for each node is this:
{
"id" : "908754897618956",
"currentStatus" : "Active",
}
or even:
[ "908754897618956", "Active" ]
Is that achievable? When I'm requesting hundreds of thousands of nodes it makes quite a big difference.
There is no config option to tweak this for the existing
db/data/nodeREST endpoint.As Christophe sketched you can use the transactional endpoint and a tailored Cypher statement to return those properties you want to see.
The other option is writing your own unmanaged extension to the Neo4j server that returns the nodes as you've specified.
The lowest hanging fruit is for sure the first approach.