use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchModifierTest method testLimitQuery.
@Test
public void testLimitQuery() {
Var t = var("t");
Match match = qb.match(x.isa("movie").has("title", t)).orderBy(t, asc).offset(1).limit(3);
assertResultsOrderedByValue(match, t, true);
assertEquals(3, match.stream().count());
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchModifierTest method testVoteCountOrderedQuery.
@Test
public void testVoteCountOrderedQuery() {
Var z = var("z");
Match match = qb.match(z.isa("movie").has("tmdb-vote-count", var("v"))).orderBy("v", desc);
// Make sure movies are in the correct order
assertThat(match, variable(z, contains(godfather, hocusPocus, apocalypseNow, theMuppets, chineseCoffee)));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testNoInstancesOfRoleType.
@Test
public void testNoInstancesOfRoleType() {
Match query = qb.match(x.isa(y), y.label("actor"));
assertThat(query, emptyIterable());
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method whenQueryingForAnImplicitRelationById_TheRelationIsReturned.
@Test
public void whenQueryingForAnImplicitRelationById_TheRelationIsReturned() {
Match match = qb.match(var("x").isa(label(Schema.ImplicitType.HAS.getLabel("name"))));
Relationship relationship = match.get("x").findAny().get().asRelationship();
Match queryById = qb.match(var("x").id(relationship.getId()));
assertThat(queryById, variable(x, contains(MatchableConcept.of(relationship))));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testAndOrPattern.
@Test
public void testAndOrPattern() {
Match query = qb.match(x.isa("movie"), or(and(y.isa("genre").has("name", "drama"), var().rel(x).rel(y)), x.has("title", "The Muppets")));
assertThat(query, variable(x, containsInAnyOrder(godfather, apocalypseNow, heat, theMuppets, chineseCoffee)));
}
Aggregations