use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleInCategorical_Ids.
@Test
public void generateOneQueryRuleInCategorical_Ids() {
Iterable<String> values = asList("id0", "id1", "id2");
Query<Entity> q = new QueryImpl<>().in(categoricalAttrName, values);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = constantScoreQuery(nestedQuery(categoricalAttrName, termsQuery(categoricalAttrName + '.' + idAttrName + '.' + FIELD_NOT_ANALYZED, new Object[] { "id0", "id1", "id2" }), ScoreMode.Avg));
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleInEnum.
@Test
public void generateOneQueryRuleInEnum() {
String value1 = "enum0";
String value2 = "enum1";
Iterable<Object> values = Arrays.asList(value1, value2);
Query<Entity> q = new QueryImpl<>().in(enumAttrName, values);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = constantScoreQuery(termsQuery(enumAttrName + '.' + FIELD_NOT_ANALYZED, new Object[] { value1, value2 }));
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleInHtml.
@Test
public void generateOneQueryRuleInHtml() {
String value1 = "<h1>title</h1>";
String value2 = "<h2>subtitle</h2>";
Iterable<Object> values = Arrays.asList(value1, value2);
Query<Entity> q = new QueryImpl<>().in(htmlAttrName, values);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = constantScoreQuery(termsQuery(htmlAttrName + '.' + FIELD_NOT_ANALYZED, new Object[] { value1, value2 }));
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleGreaterEqualInt.
@Test
public void generateOneQueryRuleGreaterEqualInt() {
Integer value = 1;
Query<Entity> q = new QueryImpl<>().ge(intAttrName, value);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = constantScoreQuery(rangeQuery(intAttrName).gte(value));
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.index.query.QueryBuilder in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleSearchOneFieldEnum.
@Test
public void generateOneQueryRuleSearchOneFieldEnum() {
String value = "enum0";
Query<Entity> q = new QueryImpl<>().search(enumAttrName, value);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = matchQuery(enumAttrName, value);
assertQueryBuilderEquals(query, expectedQuery);
}
Aggregations