use of com.enonic.xp.repo.impl.elasticsearch.query.translator.resolver.SearchQueryFieldNameResolver in project xp by enonic.
the class TermExpressionBuilderTest method compare_eq_datetime.
@Test
public void compare_eq_datetime() throws Exception {
final String expected = load("compare_eq_datetime.json");
final QueryBuilder query = TermExpressionBuilder.build(CompareExpr.eq(FieldExpr.from("myField"), ValueExpr.instant("2013-11-29T09:42:00Z")), new SearchQueryFieldNameResolver());
assertEquals(cleanString(expected), cleanString(query.toString()));
}
use of com.enonic.xp.repo.impl.elasticsearch.query.translator.resolver.SearchQueryFieldNameResolver in project xp by enonic.
the class IndexNodeIndexPathResolverTest method testResolve.
@ParameterizedTest
@MethodSource("testParams")
public void testResolve(final String field, final ValueExpr valueExpr, final String resolvedFieldName) {
final String result = new SearchQueryFieldNameResolver().resolve(CompareExpr.eq(FieldExpr.from(field), valueExpr));
assertEquals(resolvedFieldName, result);
}
use of com.enonic.xp.repo.impl.elasticsearch.query.translator.resolver.SearchQueryFieldNameResolver in project xp by enonic.
the class CopyExecutor method createQuery.
private ElasticsearchQuery createQuery() {
final IdFilter idFilter = IdFilter.create().fieldName(NodeIndexPath.ID.getPath()).values(copyRequest.getNodeIds()).build();
final QueryBuilder idFilterBuilder = new FilterBuilderFactory(new SearchQueryFieldNameResolver()).create(Filters.from(idFilter));
QueryBuilder query = QueryBuilders.matchAllQuery();
return ElasticsearchQuery.create().query(QueryBuilders.filteredQuery(query, idFilterBuilder)).addIndexName(copyRequest.getStorageSource().getStorageName().getName()).addIndexType(copyRequest.getStorageSource().getStorageType().getName()).size(copyRequest.getNodeIds().getSize()).batchSize(BATCH_SIZE).from(0).setReturnFields(ReturnFields.from(NodeIndexPath.SOURCE)).build();
}
use of com.enonic.xp.repo.impl.elasticsearch.query.translator.resolver.SearchQueryFieldNameResolver in project xp by enonic.
the class FilterBuilderFactoryTest method createExistsFilter.
@Test
public void createExistsFilter() throws Exception {
final ExistsFilter queryFilter = ExistsFilter.create().fieldName("myField").build();
final String expected = load("filter_exists.json");
final QueryBuilder filterBuilder = new FilterBuilderFactory(new SearchQueryFieldNameResolver()).create(Filters.from(queryFilter));
assertEquals(cleanString(expected), cleanString(filterBuilder.toString()));
}
use of com.enonic.xp.repo.impl.elasticsearch.query.translator.resolver.SearchQueryFieldNameResolver in project xp by enonic.
the class SortBuilderFactoryTest method createGeoDistance.
@Test
public void createGeoDistance() {
final Set<OrderExpr> orderExprs = new HashSet<>();
orderExprs.add(new DynamicOrderExpr(new FunctionExpr("geoDistance", List.of(ValueExpr.string("myField"), ValueExpr.geoPoint("-50,40"), ValueExpr.string("km"))), OrderExpr.Direction.ASC));
final List<SortBuilder> sortBuilders = new SortQueryBuilderFactory(new SearchQueryFieldNameResolver()).create(orderExprs);
assertEquals(1, sortBuilders.size());
assertTrue(sortBuilders.iterator().next() instanceof GeoDistanceSortBuilder);
}
Aggregations