Search in sources :

Example 26 with SearchQueryFieldNameResolver

use of com.enonic.xp.repo.impl.elasticsearch.query.translator.resolver.SearchQueryFieldNameResolver in project xp by enonic.

the class RangeExpressionBuilderTest method compare_gte_instant.

@Test
public void compare_gte_instant() throws Exception {
    final String expected = load("compare_gt_datetime.json");
    final QueryBuilder query = RangeExpressionBuilder.build(CompareExpr.gt(FieldExpr.from("myField"), ValueExpr.instant("2013-11-29T11:00:00.000Z")), new SearchQueryFieldNameResolver());
    assertEquals(cleanString(expected), cleanString(query.toString()));
}
Also used : QueryBuilder(org.elasticsearch.index.query.QueryBuilder) SearchQueryFieldNameResolver(com.enonic.xp.repo.impl.elasticsearch.query.translator.resolver.SearchQueryFieldNameResolver) Test(org.junit.jupiter.api.Test)

Example 27 with SearchQueryFieldNameResolver

use of com.enonic.xp.repo.impl.elasticsearch.query.translator.resolver.SearchQueryFieldNameResolver in project xp by enonic.

the class InExpressionBuilderTest method compareInString.

@Test
public void compareInString() throws Exception {
    final String expected = load("compare_in_string.json");
    final QueryBuilder query = InExpressionBuilder.build(CompareExpr.in(FieldExpr.from("myField"), List.of(ValueExpr.string("myFirstValue"), ValueExpr.string("mySecondValue"))), new SearchQueryFieldNameResolver());
    assertEquals(cleanString(expected), cleanString(query.toString()));
}
Also used : QueryBuilder(org.elasticsearch.index.query.QueryBuilder) SearchQueryFieldNameResolver(com.enonic.xp.repo.impl.elasticsearch.query.translator.resolver.SearchQueryFieldNameResolver) Test(org.junit.jupiter.api.Test)

Example 28 with SearchQueryFieldNameResolver

use of com.enonic.xp.repo.impl.elasticsearch.query.translator.resolver.SearchQueryFieldNameResolver in project xp by enonic.

the class TermExpressionBuilderTest method compare_eq_string.

@Test
public void compare_eq_string() throws Exception {
    final String expected = load("compare_eq_string.json");
    final QueryBuilder query = TermExpressionBuilder.build(CompareExpr.eq(FieldExpr.from("myField"), ValueExpr.string("myValue")), new SearchQueryFieldNameResolver());
    assertEquals(cleanString(expected), cleanString(query.toString()));
}
Also used : QueryBuilder(org.elasticsearch.index.query.QueryBuilder) SearchQueryFieldNameResolver(com.enonic.xp.repo.impl.elasticsearch.query.translator.resolver.SearchQueryFieldNameResolver) Test(org.junit.jupiter.api.Test)

Aggregations

SearchQueryFieldNameResolver (com.enonic.xp.repo.impl.elasticsearch.query.translator.resolver.SearchQueryFieldNameResolver)28 Test (org.junit.jupiter.api.Test)24 QueryBuilder (org.elasticsearch.index.query.QueryBuilder)18 GeoDistanceSortBuilder (org.elasticsearch.search.sort.GeoDistanceSortBuilder)8 DslOrderExpr (com.enonic.xp.query.expr.DslOrderExpr)7 FieldSortBuilder (org.elasticsearch.search.sort.FieldSortBuilder)6 SortBuilder (org.elasticsearch.search.sort.SortBuilder)6 DynamicOrderExpr (com.enonic.xp.query.expr.DynamicOrderExpr)5 FieldOrderExpr (com.enonic.xp.query.expr.FieldOrderExpr)5 OrderExpr (com.enonic.xp.query.expr.OrderExpr)5 HashSet (java.util.HashSet)5 FunctionExpr (com.enonic.xp.query.expr.FunctionExpr)3 ValueFilter (com.enonic.xp.query.filter.ValueFilter)3 PropertyTree (com.enonic.xp.data.PropertyTree)2 PropertySet (com.enonic.xp.data.PropertySet)1 CompareExpr (com.enonic.xp.query.expr.CompareExpr)1 QueryExpr (com.enonic.xp.query.expr.QueryExpr)1 BooleanFilter (com.enonic.xp.query.filter.BooleanFilter)1 ExistsFilter (com.enonic.xp.query.filter.ExistsFilter)1 IdFilter (com.enonic.xp.query.filter.IdFilter)1