use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleEqualsEmailNull.
@Test
public void generateOneQueryRuleEqualsEmailNull() {
String value = null;
Query<Entity> q = new QueryImpl<>().eq(emailAttrName, value);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = constantScoreQuery(boolQuery().mustNot(existsQuery(emailAttrName)));
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project molgenis by molgenis.
the class QueryGeneratorTest method generateMultipleQueryRule.
@Test
public void generateMultipleQueryRule() {
// query: a or (b and c)
Boolean booleanValue = Boolean.TRUE;
String stringValue = "str";
Integer intValue = 1;
Query<Entity> q = new QueryImpl<>().eq(boolAttrName, booleanValue).or().nest().eq(stringAttrName, stringValue).and().eq(intAttrName, intValue).unnest();
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder booleanQuery = constantScoreQuery(termQuery(boolAttrName, booleanValue));
QueryBuilder stringQuery = constantScoreQuery(termQuery(stringAttrName + '.' + FIELD_NOT_ANALYZED, stringValue));
QueryBuilder intQuery = constantScoreQuery(termQuery(intAttrName, intValue));
BoolQueryBuilder stringIntQuery = boolQuery().must(stringQuery).must(intQuery);
QueryBuilder expectedQuery = boolQuery().should(booleanQuery).should(stringIntQuery).minimumShouldMatch(1);
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleSearchOneFieldDateTime.
@Test
public void generateOneQueryRuleSearchOneFieldDateTime() throws ParseException {
String value = "2015-05-22T06:12:13Z";
Query<Entity> q = new QueryImpl<>().search(dateTimeAttrName, value);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = matchQuery(dateTimeAttrName, value);
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleNotEqualsEnumNull.
@Test
public void generateOneQueryRuleNotEqualsEnumNull() {
String value = null;
Query<Entity> q = new QueryImpl<>().not().eq(enumAttrName, value);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = boolQuery().mustNot(constantScoreQuery(boolQuery().mustNot(existsQuery(enumAttrName))));
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleGreaterEqualDateTime.
@Test
public void generateOneQueryRuleGreaterEqualDateTime() throws ParseException {
Instant value = Instant.parse("2015-05-22T06:12:13Z");
Query<Entity> q = new QueryImpl<>().ge(dateTimeAttrName, value);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = constantScoreQuery(rangeQuery(dateTimeAttrName).gte(DataConverter.toString(value)));
assertQueryBuilderEquals(query, expectedQuery);
}
Aggregations