How to get Resource from Entity when connect with Relation?


I have 2 entity, entity was connect with relation ‘edge’ like the picture.

So far I try from this code,but nol solved.

qb.match(var("x").isa("person").has("firstname", "Andrea").rel("edge"));

What Should I do for get All Resource by java code ??



OK the actual syntax I think you would like is this:

match(var().isa("edge").rel("x").rel("y"), var("x").isa("person").has("firstname", "Andrea"))

To explain why the syntax looks like this I will write the equivalent Graql query

match                      ($x,      $y);      $x isa    person has    firstname   "Andrea";

The brackets represent a relation which has the syntax var().rel().rel() where the first var is the relation concept itself. We will review the syntax as there might be a better way to express this.

Let me know if this works for you.



thanks @sheldon
I try the graql its solved.

but when i use your example code, i cant get the value.
whats should I do ?

so far i try with the code :

	    query = qb.match(var().isa("edge").rel("x").rel("y"), var("x").isa("person").has("firstname", "Andrea").has("firstname", var("name")));
		for (Map<String, Concept> result : query) {
			Resource<Object> firstName = (Resource<Object>) result.get("name");
			System.out.println("value : "+firstName.getValue());


Could you tell me what the answer you expect is. I am a little unsure what you are trying to achieve. Do you:

  1. want to get back the resource with value “Andrea”
  2. want to get the value of y which is a resource attached to “Andrea” by edge


I Apologiz @sheldon , I think i want to do this.

and I want to attach the resource of the edge.


This will get what you y which is attached to the person Andrea:

List<Answer> result = match(var().isa("edge").rel("x").rel("y"), var("x").isa("person").has("firstname", "Andrea"), var("y")).execute();

Do you want to do anything more with the resource?