use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method whenQueryingForHas_AllowReferringToTheImplicitRelation.
@Test
public void whenQueryingForHas_AllowReferringToTheImplicitRelation() {
Label title = Label.of("title");
RelationshipType hasTitle = movieKB.tx().getType(HAS.getLabel(title));
Role titleOwner = movieKB.tx().getSchemaConcept(HAS_OWNER.getLabel(title));
Role titleValue = movieKB.tx().getSchemaConcept(HAS_VALUE.getLabel(title));
Relationship implicitRelation = hasTitle.instances().iterator().next();
ConceptId owner = implicitRelation.rolePlayers(titleOwner).iterator().next().getId();
ConceptId value = implicitRelation.rolePlayers(titleValue).iterator().next().getId();
Match query = qb.match(x.id(owner).has(title, y.id(value), r));
assertThat(query, variable(r, contains(MatchableConcept.of(implicitRelation))));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testMoviesHasHigherTmdbCount.
@Test
public void testMoviesHasHigherTmdbCount() {
Match query = qb.match(x.has("tmdb-vote-count", lt(r)), var().has("title", "The Muppets").has("tmdb-vote-count", r));
assertThat(query, variable(x, contains(chineseCoffee)));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testDontHideImplicitTypesIfExplicitlyMentioned.
@Test
public void testDontHideImplicitTypesIfExplicitlyMentioned() {
Match query = qb.match(x.sub(Schema.MetaSchema.THING.getLabel().getValue()).label(HAS.getLabel("title")));
assertThat(query, variable(x, (Matcher) hasItem(hasTitle)));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method whenQueryingForAResourceWhichHasItselfAsAResource_ReturnTheResource.
@Test
public void whenQueryingForAResourceWhichHasItselfAsAResource_ReturnTheResource() {
Match query = weirdKB.tx().graql().match(var("x").has("name", var("x")));
assertThat(query, variable(x, contains(hasValue("weird"))));
}
use of ai.grakn.graql.Match in project grakn by graknlabs.
the class MatchTest method testHasVariable.
@Test
public void testHasVariable() {
Match query = qb.match(var().has("title", "Godfather").has("tmdb-vote-count", x));
assertThat(query, variable(x, contains(hasValue(1000L))));
}
Aggregations