Java Code Examples for org.neo4j.graphdb.GraphDatabaseService#execute()
The following examples show how to use
org.neo4j.graphdb.GraphDatabaseService#execute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomerProceduresTest.java From ongdb-lab-apoc with Apache License 2.0 | 6 votes |
@Test public void testRecommend() { GraphDatabaseService db = neo4j.getGraphDatabaseService(); try (Transaction tx = db.beginTx()) { // CALL training.recommendOnly("Dee Dee Titley_0_linkedin") YIELD stringObjectMap RETURN stringObjectMap // Result res = db.execute("CALL training.recommendOnly(\"Dee Dee Titley_0_linkedin\") YIELD stringObjectMap RETURN stringObjectMap"); Result res = db.execute("CALL zdr.index.search('linkin', 'name:china*', 10) YIELD node RETURN node"); // // System.out.println(res.resultAsString()); // System.out.println(res.next()); // Node node = (Node) res.next().get("stringObjectMap"); // CustomerProcedures.Movie movie = (CustomerProcedures.Movie) res.next().get("stringObjectMap"); // movie.stringObjectMap.forEach((k, v) -> System.out.println("key:value = " + k + ":" + v)); // System.out.println(node.getId()); // System.out.println(node.getLabels()); // System.out.println(node.getRelationships()); } }
Example 2
Source File: UnionFindPerformance.java From graph_processing with MIT License | 5 votes |
private void populateDb(GraphDatabaseService db) { try ( Transaction tx = db.beginTx()) { db.execute(TestObjects.MOVIES_QUERY); db.execute(TestObjects.KNOWS_QUERY); tx.success(); } }
Example 3
Source File: Neo4jModuleTest.java From SciGraph with Apache License 2.0 | 5 votes |
@Test(expected = WriteOperationsNotAllowedException.class) public void graphDbReadOnlyWithCypher() { GraphDatabaseService graphDb = injectorReadOnly.getInstance(GraphDatabaseService.class); Transaction tx = graphDb.beginTx(); try { graphDb.execute("CREATE (n: test)"); } finally { tx.close(); } }
Example 4
Source File: LabelPropagationTest.java From graph_processing with MIT License | 5 votes |
private void populateDb(GraphDatabaseService db) { try ( Transaction tx = db.beginTx()) { db.execute(TestObjects.MOVIES_QUERY); db.execute(TestObjects.KNOWS_QUERY); tx.success(); } }
Example 5
Source File: BetweenessCentralityTest.java From graph_processing with MIT License | 5 votes |
private void populateDb(GraphDatabaseService db) { try ( Transaction tx = db.beginTx()) { db.execute(TestObjects.MOVIES_QUERY); db.execute(TestObjects.KNOWS_QUERY); tx.success(); } }
Example 6
Source File: LabelPropagationPerformance.java From graph_processing with MIT License | 5 votes |
private void populateDb(GraphDatabaseService db) { try ( Transaction tx = db.beginTx()) { db.execute(TestObjects.MOVIES_QUERY); db.execute(TestObjects.KNOWS_QUERY); tx.success(); } }
Example 7
Source File: PageRankPerformance.java From graph_processing with MIT License | 5 votes |
private void populateDb(GraphDatabaseService db) { try ( Transaction tx = db.beginTx()) { db.execute(TestObjects.MOVIES_QUERY); db.execute(TestObjects.KNOWS_QUERY); tx.success(); } }
Example 8
Source File: BasePerformanceTest.java From graph_processing with MIT License | 5 votes |
private void populateDb(GraphDatabaseService db) { try ( Transaction tx = db.beginTx()) { db.execute(TestObjects.MOVIES_QUERY); db.execute(TestObjects.KNOWS_QUERY); tx.success(); } }
Example 9
Source File: ShortestPathTest.java From ongdb-lab-apoc with Apache License 2.0 | 5 votes |
@Test public void allPathsTightness() { GraphDatabaseService db = neo4j.getGraphDatabaseService(); try (Transaction tx = db.beginTx()) { List<Long> sourceIds = new ArrayList<>(); sourceIds.add(123l); sourceIds.add(223l); sourceIds.add(223l); List<Long> targetIds = new ArrayList<>(); targetIds.add(32423l); targetIds.add(4353l); targetIds.add(4353l); List<Double> distanceSTE = new ArrayList<>(); distanceSTE.add(23.0); distanceSTE.add(324.0); distanceSTE.add(324.0); Map<String, Object> map = new HashMap<>(); map.put("sourceIds", sourceIds); map.put("targetIds", targetIds); map.put("distanceSTE", distanceSTE); Result res = db.execute("CALL zdr.shortestPath.allPathsTightness({sourceIds},{targetIds},{distanceSTE}) YIELD source,target,distance,tightnessSort RETURN source,target,distance,tightnessSort", map); while (res.hasNext()) { Map map2 = res.next(); System.out.println(map2.get("source") + " " + map2.get("target") + " " + map2.get("distance") + " " + map2.get("tightnessSort")); } } }
Example 10
Source File: PageRankTest.java From graph_processing with MIT License | 5 votes |
private static void populateDb(GraphDatabaseService db) { try ( Transaction tx = db.beginTx()) { db.execute(TestObjects.MOVIES_QUERY); db.execute(TestObjects.KNOWS_QUERY); tx.success(); } }
Example 11
Source File: UnionFindTest.java From graph_processing with MIT License | 5 votes |
private void populateDb(GraphDatabaseService db) { try ( Transaction tx = db.beginTx()) { db.execute(TestObjects.MOVIES_QUERY); db.execute(TestObjects.KNOWS_QUERY); tx.success(); } }
Example 12
Source File: DegreeCentralityTest.java From graph_processing with MIT License | 5 votes |
private void populateDb(GraphDatabaseService db) { try ( Transaction tx = db.beginTx()) { db.execute(TestObjects.MOVIES_QUERY); db.execute(TestObjects.KNOWS_QUERY); tx.success(); } }
Example 13
Source File: ClosenessCentralityTest.java From graph_processing with MIT License | 5 votes |
private void populateDb(GraphDatabaseService db) { try ( Transaction tx = db.beginTx()) { db.execute(TestObjects.MOVIES_QUERY); db.execute(TestObjects.KNOWS_QUERY); tx.success(); } }
Example 14
Source File: FreetextIKTest.java From ongdb-lab-apoc with Apache License 2.0 | 5 votes |
@Test public void iKAnalyzer() { GraphDatabaseService db = neo4j.getGraphDatabaseService(); Map<String, Object> map = new HashMap<>(); String text = "复联终章快上映了好激动,据说知识图谱与人工智能技术应用到了那部电影!吖啶基氨基甲烷磺酰甲氧基苯胺是一种药嘛?"; map.put("text", text); map.put("useSmart", true); Result res = db.execute("RETURN zdr.index.iKAnalyzer({text},{useSmart}) AS words", map); List<String> words = (List<String>) res.next().get("words"); System.out.println(JSONArray.parseArray(JSON.toJSONString(words))); }
Example 15
Source File: TestUtils.java From graph_processing with MIT License | 4 votes |
static public Map<String, Object> getPersonEntry(String name, GraphDatabaseService db) { try (Result result = db.execute(TestObjects.PERSON_RESULT_QUERY, Collections.singletonMap("name", name))) { return result.next(); } }
Example 16
Source File: TestUtils.java From graph_processing with MIT License | 4 votes |
static public Map<String, Object> getMovieEntry(String title, GraphDatabaseService db) { try (Result result = db.execute(TestObjects.MOVIE_RESULT_QUERY, Collections.singletonMap("title", title))) { return result.next(); } }
Example 17
Source File: NodeCounter.java From graph_processing with MIT License | 4 votes |
public int getRelationshipCount(GraphDatabaseService db) { Result result = db.execute( "MATCH ()-[r]->() RETURN max(id(r)) AS maxId" ); return ((Number) result.next().get( "maxId" )).intValue() + 1; }
Example 18
Source File: NodeCounter.java From graph_processing with MIT License | 4 votes |
public int getNodeCount(GraphDatabaseService db) { Result result = db.execute( "MATCH (n) RETURN max(id(n)) AS maxId" ); return ((Number) result.next().get( "maxId" )).intValue() + 1; }
Example 19
Source File: GraphManagerTest.java From graphify with Apache License 2.0 | 4 votes |
private static String executeCypher(GraphDatabaseService db, String cypher, Map<String, Object> params) { Result result; List<Map<String, Object>> results = new ArrayList<>(); try ( Transaction tx = db.beginTx() ) { result = db.execute(cypher, params); tx.success(); while (result.hasNext()) { results.add(result.next()); } tx.success(); tx.close(); } return new Gson().toJson(results); }