I am trying to run opencypher query using CypherGremlinClient.
this is how i initiate CypherGremlinClient.
org.apache.commons.configuration.Configuration configuration = new BaseConfiguration();
configuration.setProperty("port", neptuneProp.getPort());
configuration.setProperty("hosts", neptuneProp.getOpencypherhost());
configuration.setProperty("connectionPool.enableSsl", "true");
Cluster cluster = Cluster.open(configuration);
Client gremlinClient = cluster.connect();
return CypherGremlinClient.translating(gremlinClient);
My query is
MATCH p=(n)-[r]->(d) WHERE ID(n) = '123' RETURN n,r
this returns results with all attributes including ~id,~label which I need it for node and for Edges i am looking into ~id, _inV, _outV. but this query is running slow, most of the time I get memory error from neptune server.
Other side i am using below method which is executing query faster but does not return attributes that i am looking for.
Config neptunePropOpencypherConfig = Config.builder()
.withConnectionTimeout(30, TimeUnit.SECONDS)
.withMaxConnectionPoolSize(1000)
.withDriverMetrics()
.withLeakedSessionsLogging()
.withEncryption()
.withTrustStrategy(Config.TrustStrategy.trustSystemCertificates())
.build();
GraphDatabase.driver("bolt://" neptune.getHost() + ":" + neptuneProp.getPort(), neptunePropOpencypherConfig)
please help me to run my query faster with CypherGremlinClient or help me to get all other attributes using
Transaction readTx = readDiver.session().beginTransaction();
Result results = readTx.run("MATCH p=(n)-[r]->(d) WHERE ID(n) = '" + wgiId + "' RETURN n,r");
or if you know then suggest another approach.
I am looking for this kind of response.
{
"results": [
{
"n": {
"~id": "123",
"~entityType": "node",
"~labels": [
"ontology"
],
"~properties": {
"lastrevid": 0,
"P98": "1151332690",
"labels": "{ \"de\" : [ \"Ivan Shedoff\" ] }",
"aliases": "{ \"de\" : [ \"Ivan Shedoff\" ] }",
"description": "{ }",
"P26": "4.61517E+19"
}
},
"r": {
"~id": "123$11d27a77-1227-422c-9134-6e96d1cb7c79",
"~entityType": "relationship",
"~start": "123",
"~end": "Q3",
"~type": "claim",
"~properties": {
"claimCode": "P5"
}
}
}
]
}