use of com.b2international.index.query.Expression in project snow-owl by b2ihealthcare.
the class SingleDocumentRevisionIndexSearchTest method searchWithFilter.
@Test
public void searchWithFilter() throws Exception {
final RevisionData first = new RevisionData(STORAGE_KEY1, "field1", "field2");
final RevisionData second = new RevisionData(STORAGE_KEY2, "field1", "field2");
indexRevision(MAIN, first, second);
final Expression expression = Expressions.builder().filter(Expressions.exactMatch("field1", "field1")).build();
final Query<RevisionData> query = Query.select(RevisionData.class).where(expression).build();
final Iterable<RevisionData> matches = search(MAIN, query);
assertThat(matches).hasSize(2);
assertThat(matches).containsAll(Lists.newArrayList(first, second));
}
use of com.b2international.index.query.Expression in project snow-owl by b2ihealthcare.
the class SingleDocumentRevisionIndexSearchTest method searchWithMatchRange.
@Test
public void searchWithMatchRange() throws Exception {
final RangeData first = new RangeData(STORAGE_KEY1, "field1", "field2", null, 2, 4);
final RangeData second = new RangeData(STORAGE_KEY2, "field1", "field2", null, 3, 5);
indexRevision(MAIN, first, second);
final Expression expression = Expressions.builder().filter(Expressions.matchRange("from", 2, 3)).filter(Expressions.matchRange("to", 3, 4)).build();
final Query<RangeData> query = Query.select(RangeData.class).where(expression).build();
final Iterable<RangeData> matches = search(MAIN, query);
assertThat(matches).hasSize(1);
assertThat(matches).containsOnly(first);
}
use of com.b2international.index.query.Expression in project snow-owl by b2ihealthcare.
the class BoolQueryTest method mergeDisjunctTermFilterClauses.
@Test
public void mergeDisjunctTermFilterClauses() throws Exception {
String id1 = UUID.randomUUID().toString();
String id2 = UUID.randomUUID().toString();
String id3 = UUID.randomUUID().toString();
String id4 = UUID.randomUUID().toString();
Expression actual = Expressions.bool().filter(Expressions.exactMatch("id", id1)).filter(Expressions.matchAny("id", Set.of(id2, id3))).filter(Expressions.matchAny("id", Set.of(id3, id4))).build();
assertEquals(Expressions.matchNone(), actual);
}
use of com.b2international.index.query.Expression in project snow-owl by b2ihealthcare.
the class BoolQueryTest method mergeSingleTermShouldClauses.
@Test
public void mergeSingleTermShouldClauses() throws Exception {
String id1 = UUID.randomUUID().toString();
String id2 = UUID.randomUUID().toString();
String id3 = UUID.randomUUID().toString();
Expression actual = Expressions.bool().should(Expressions.exactMatch("id", id1)).should(Expressions.exactMatch("id", id2)).should(Expressions.exactMatch("id", id3)).build();
assertEquals(Expressions.matchAny("id", Set.of(id1, id2, id3)), actual);
}
use of com.b2international.index.query.Expression in project snow-owl by b2ihealthcare.
the class SnomedEclEvaluationRequestTest method refinementWithAttributeDisjunction.
@Test
public void refinementWithAttributeDisjunction() throws Exception {
generateDrugHierarchy();
generateTisselKit();
final Expression actual = eval(String.format("<%s:%s=%s OR %s=%s", DRUG_ROOT, HAS_ACTIVE_INGREDIENT, INGREDIENT2, HAS_ACTIVE_INGREDIENT, INGREDIENT4));
final Expression expected = Expressions.builder().should(and(descendantsOf(DRUG_ROOT), ids(Set.of(TRIPHASIL_TABLET)))).should(and(descendantsOf(DRUG_ROOT), ids(Set.of(TISSEL_KIT)))).build();
assertEquals(expected, actual);
}
Aggregations