use of com.enonic.xp.query.expr.ValueExpr in project xp by enonic.
the class RangeFunctionArgsFactory method create.
public static RangeFunctionArg create(final List<ValueExpr> arguments) {
validateArguments(arguments);
final String fieldName = arguments.get(FIELDNAME_INDEX).getValue().asString();
final ValueExpr from = arguments.get(FROM_INDEX);
final ValueExpr to = arguments.get(TO_INDEX);
boolean includeFrom = false;
boolean includeTo = false;
if (arguments.size() >= 4) {
includeFrom = arguments.get(INCLUDE_FROM_INDEX).getValue().asBoolean();
}
if (arguments.size() >= 5) {
includeTo = arguments.get(INCLUDE_TO_INDEX).getValue().asBoolean();
}
if (isInstant(from.getValue(), to.getValue()) || isInstantString(from.getValue(), to.getValue())) {
return createInstantArgs(fieldName, from, to, includeFrom, includeTo);
}
if (isNumeric(from.getValue(), to.getValue())) {
return createNumericArgs(fieldName, from, to, includeFrom, includeTo);
}
return createStringArgs(fieldName, from, to, includeFrom, includeTo);
}
use of com.enonic.xp.query.expr.ValueExpr in project xp by enonic.
the class InExpressionBuilder method build.
public static QueryBuilder build(final CompareExpr compareExpr, final QueryFieldNameResolver resolver) {
final String queryFieldName = resolver.resolve(compareExpr.getField().getFieldPath());
final List<ValueExpr> values = compareExpr.getValues();
if (values == null || values.size() == 0) {
throw new IndexQueryBuilderException("Cannot build empty 'IN' statements");
}
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
for (ValueExpr value : values) {
boolQuery.should(TermExpressionBuilder.build(queryFieldName, value.getValue()));
}
return boolQuery;
}
use of com.enonic.xp.query.expr.ValueExpr in project xp by enonic.
the class AbstractQueryFieldNameResolver method resolve.
@Override
public String resolve(final CompareExpr compareExpr) {
final FieldExpr field = compareExpr.getField();
final String baseFieldName = IndexFieldNameNormalizer.normalize(field.getFieldPath());
final ValueExpr firstValue = compareExpr.getFirstValue();
if (firstValue == null) {
return "";
}
return createValueTypeAwareFieldName(baseFieldName, firstValue.getValue());
}
use of com.enonic.xp.query.expr.ValueExpr in project xp by enonic.
the class FindNodeIdsByParentCommand method createParentFilter.
private void createParentFilter(final NodePath parentPath, final NodeQuery.Builder builder) {
if (parentPath.isRoot()) {
final ValueExpr parentPathExpr = ValueExpr.string("/*");
builder.query(QueryExpr.from(CompareExpr.like(FieldExpr.from(NodeIndexPath.PARENT_PATH), parentPathExpr)));
} else {
final ValueExpr parentPathExpr = ValueExpr.string(parentPath + "/*");
builder.query(QueryExpr.from(CompareExpr.like(FieldExpr.from(NodeIndexPath.PATH), parentPathExpr)));
}
}
use of com.enonic.xp.query.expr.ValueExpr in project xp by enonic.
the class FunctionExpressionBuilderTest method test_fulltext.
@Test
public void test_fulltext() {
List<ValueExpr> arguments = List.of(ValueExpr.string("myField"), ValueExpr.string("mySearchString"), ValueExpr.string("OR"));
final QueryBuilder fulltext = FunctionExpressionBuilder.build(new FunctionExpr("fulltext", arguments));
assertTrue(fulltext instanceof SimpleQueryStringBuilder);
}
Aggregations