2017-10-10 2 views
3

일부 작업을 자동화하기 위해 Java API를 사용하기 시작했습니다. Visualizer 및 셸에서 실행할 수있는 graql 쿼리를 Java API와 함께 사용할 수있는 간단한 메서드로 변환하는 간단한 방법이 있습니까? 예를 들어Graql에서 Java API로 변환

쿼리 :

match $x isa product 

내가

match(var("x").isa("product")); 

자동으로 자바 형식으로 문자열 형식을지도 할 수있는 방법이 없다는 것을 쓸 수 있는지 볼 수?

나는 간단한 것을 놓치고 있다고 느낍니다.

감사합니다.

키어런.

답변

3

당신은 QueryBuilder https://grakn.ai/pages/documentation/developing-with-java/java-graql.html#query-parser

for (Concept x : qb.<MatchQuery>parse("match $x isa person;").get("x")) { 
    System.out.println(x); 
} 

if (qb.<AskQuery>parse("match has name 'Bob' isa person; ask;").execute()) 
{ 
    System.out.println("There is someone called Bob!"); 
} 

qb.parse("insert isa person, has firstname 'Alice';").execute(); 

qb.parse("match $x isa person; delete $x;").execute(); 
을 사용할 수 있습니다