Search in sources :

Example 71 with Expression

use of com.b2international.index.query.Expression in project snow-owl by b2ihealthcare.

the class SnomedEclRefinementEvaluator method eval.

/**
 * Handles disjunctions in refinement part of refined expression constraints.
 * @see https://confluence.ihtsdotools.org/display/DOCECL/6.4+Conjunction+and+Disjunction
 */
protected Promise<Expression> eval(final BranchContext context, OrRefinement or) {
    return Promise.all(evaluate(context, or.getLeft()), evaluate(context, or.getRight())).then(input -> {
        final Expression left = (Expression) input.get(0);
        final Expression right = (Expression) input.get(1);
        return Expressions.builder().should(left).should(right).build();
    });
}
Also used : Expression(com.b2international.index.query.Expression)

Example 72 with Expression

use of com.b2international.index.query.Expression in project snow-owl by b2ihealthcare.

the class SnomedEclRefinementEvaluator method eval.

/**
 * Handles conjunctions in refinement part of refined expression constraints.
 * @see https://confluence.ihtsdotools.org/display/DOCECL/6.4+Conjunction+and+Disjunction
 */
protected Promise<Expression> eval(final BranchContext context, AndRefinement and) {
    return Promise.all(evaluate(context, and.getLeft()), evaluate(context, and.getRight())).then(input -> {
        final Expression left = (Expression) input.get(0);
        final Expression right = (Expression) input.get(1);
        return Expressions.builder().filter(left).filter(right).build();
    });
}
Also used : Expression(com.b2international.index.query.Expression)

Example 73 with Expression

use of com.b2international.index.query.Expression in project snow-owl by b2ihealthcare.

the class SingleDocumentRevisionIndexSearchTest method searchWithMinimumShouldMatch.

@Test
public void searchWithMinimumShouldMatch() throws Exception {
    final RevisionData first = new RevisionData(STORAGE_KEY1, "field1", "field1");
    final RevisionData second = new RevisionData(STORAGE_KEY2, "field1", "field2");
    indexRevision(MAIN, first, second);
    final Expression expression = Expressions.builder().should(Expressions.exactMatch("field1", "field1")).should(Expressions.exactMatch("field2", "field2")).setMinimumNumberShouldMatch(2).build();
    final Query<RevisionData> query = Query.select(RevisionData.class).where(expression).build();
    final Iterable<RevisionData> matches = search(MAIN, query);
    assertThat(matches).hasSize(1);
    assertThat(matches).containsOnly(second);
}
Also used : Expression(com.b2international.index.query.Expression) RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 74 with Expression

use of com.b2international.index.query.Expression in project snow-owl by b2ihealthcare.

the class SnomedEclShortcutTest method queryMinusNestedAll.

@Test
public void queryMinusNestedAll() throws Exception {
    final Expression actual = eval(ROOT_ID + " MINUS (*)");
    final Expression expected = Expressions.matchNone();
    assertEquals(expected, actual);
}
Also used : Expression(com.b2international.index.query.Expression) Test(org.junit.Test) BaseRevisionIndexTest(com.b2international.index.revision.BaseRevisionIndexTest)

Example 75 with Expression

use of com.b2international.index.query.Expression in project snow-owl by b2ihealthcare.

the class SnomedEclShortcutTest method queryAndNestedAll.

@Test
public void queryAndNestedAll() throws Exception {
    final Expression actual = eval(ROOT_ID + " AND (*)");
    final Expression expected = SnomedConceptDocument.Expressions.id(ROOT_ID);
    assertEquals(expected, actual);
}
Also used : Expression(com.b2international.index.query.Expression) Test(org.junit.Test) BaseRevisionIndexTest(com.b2international.index.revision.BaseRevisionIndexTest)

Aggregations

Expression (com.b2international.index.query.Expression)151 Test (org.junit.Test)142 BaseRevisionIndexTest (com.b2international.index.revision.BaseRevisionIndexTest)8 Ignore (org.junit.Ignore)5 Expressions (com.b2international.index.query.Expressions)2 ExpressionBuilder (com.b2international.index.query.Expressions.ExpressionBuilder)2 RevisionData (com.b2international.index.revision.RevisionFixtures.RevisionData)2 RevisionSearcher (com.b2international.index.revision.RevisionSearcher)2 BranchContext (com.b2international.snowowl.core.domain.BranchContext)2 Options (com.b2international.commons.options.Options)1 BulkUpdate (com.b2international.index.BulkUpdate)1 Searcher (com.b2international.index.Searcher)1 Query (com.b2international.index.query.Query)1 RangeData (com.b2international.index.revision.RevisionFixtures.RangeData)1 Ecl (com.b2international.snomed.ecl.Ecl)1 Any (com.b2international.snomed.ecl.ecl.Any)1 EclConceptReference (com.b2international.snomed.ecl.ecl.EclConceptReference)1 ExpressionConstraint (com.b2international.snomed.ecl.ecl.ExpressionConstraint)1 NestedExpression (com.b2international.snomed.ecl.ecl.NestedExpression)1 ResourceURI (com.b2international.snowowl.core.ResourceURI)1