use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleNotEqualsEnum.
@Test
public void generateOneQueryRuleNotEqualsEnum() {
String value = "enum0";
Query<Entity> q = new QueryImpl<>().not().eq(enumAttrName, value);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = boolQuery().mustNot(constantScoreQuery(termQuery(enumAttrName + '.' + FIELD_NOT_ANALYZED, value)));
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleInBool.
@Test
public void generateOneQueryRuleInBool() {
Iterable<Object> values = Arrays.asList(Boolean.TRUE, Boolean.FALSE);
Query<Entity> q = new QueryImpl<>().in(boolAttrName, values);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = constantScoreQuery(termsQuery(boolAttrName, Boolean.TRUE, Boolean.FALSE));
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleSearchAllFields.
@Test
public void generateOneQueryRuleSearchAllFields() {
String value = "my text";
Query<Entity> q = new QueryImpl<>().search(value);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = matchPhraseQuery("_all", value).slop(10);
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleLikeCompoundPartString.
@Test
public void generateOneQueryRuleLikeCompoundPartString() {
String value = "value";
Query<Entity> q = new QueryImpl<>().like(compoundPart0AttrName, value);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = matchPhrasePrefixQuery(compoundPart0AttrName, value).slop(10).analyzer(DEFAULT_ANALYZER);
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleRangeLong.
@Test
public void generateOneQueryRuleRangeLong() {
Long low = 3L;
Long high = 9L;
Query<Entity> q = new QueryImpl<>().rng(longAttrName, low, high);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = constantScoreQuery(rangeQuery(longAttrName).gte(3).lte(9));
assertQueryBuilderEquals(query, expectedQuery);
}
Aggregations