Search in sources :

Example 11 with SearchQueryFieldNameResolver

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

the class RangeExpressionBuilderTest method compare_lt_number.

@Test
public void compare_lt_number() throws Exception {
    final String expected = load("compare_lt_number.json");
    final QueryBuilder query = RangeExpressionBuilder.build(CompareExpr.lt(FieldExpr.from("myField"), ValueExpr.number(3L)), 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 12 with SearchQueryFieldNameResolver

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

the class RangeExpressionBuilderTest method compare_gt_number.

@Test
public void compare_gt_number() throws Exception {
    final String expected = load("compare_gt_number.json");
    final QueryBuilder query = RangeExpressionBuilder.build(CompareExpr.gt(FieldExpr.from("myField"), ValueExpr.number(3L)), 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 13 with SearchQueryFieldNameResolver

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

the class NotQueryBuilderTest method negate_term.

@Test
public void negate_term() throws Exception {
    final String expected = load("not_term.json");
    final CompareExpr compareExpr = CompareExpr.create(FieldExpr.from("fisk"), CompareExpr.Operator.EQ, ValueExpr.string("ost"));
    final QueryBuilder query = NotQueryBuilder.build(CompareExpressionBuilder.build(compareExpr, new SearchQueryFieldNameResolver()));
    assertEquals(cleanString(expected), cleanString(query.toString()));
}
Also used : CompareExpr(com.enonic.xp.query.expr.CompareExpr) QueryBuilder(org.elasticsearch.index.query.QueryBuilder) SearchQueryFieldNameResolver(com.enonic.xp.repo.impl.elasticsearch.query.translator.resolver.SearchQueryFieldNameResolver) Test(org.junit.jupiter.api.Test)

Example 14 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_number.

@Test
public void compare_eq_number() throws Exception {
    final String expected = load("compare_eq_number.json");
    final QueryBuilder query = TermExpressionBuilder.build(CompareExpr.eq(FieldExpr.from("myField"), ValueExpr.number(1)), 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 15 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_geopoint.

@Test
public void compare_eq_geopoint() throws Exception {
    final String expected = load("compare_eq_geopoint.json");
    final QueryBuilder query = TermExpressionBuilder.build(CompareExpr.eq(FieldExpr.from("myField"), ValueExpr.geoPoint("59.9127300,10.746090")), 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