use of com.enonic.xp.query.expr.LogicalExpr in project xp by enonic.
the class ReorderChildNodeCommand method createFirstNodeBeforeInsertQuery.
private NodeQuery createFirstNodeBeforeInsertQuery(final Long nodeAfterOrderValue) {
final CompareExpr orderGreaterThanNodeToMoveBefore = CompareExpr.gt(FieldExpr.from(NodeIndexPath.MANUAL_ORDER_VALUE), ValueExpr.number(nodeAfterOrderValue));
final CompareExpr parentPathEqualToParent = CompareExpr.eq(FieldExpr.from(NodeIndexPath.PARENT_PATH), ValueExpr.string(parentNode.path().toString()));
final LogicalExpr constraint = LogicalExpr.and(orderGreaterThanNodeToMoveBefore, parentPathEqualToParent);
final FieldOrderExpr orderManuallyDesc = FieldOrderExpr.create(NodeIndexPath.MANUAL_ORDER_VALUE, OrderExpr.Direction.ASC);
return NodeQuery.create().query(QueryExpr.from(constraint, orderManuallyDesc)).size(1).build();
}
use of com.enonic.xp.query.expr.LogicalExpr in project xp by enonic.
the class PrincipalQueryNodeQueryTranslator method getQueryExpression.
private static QueryExpr getQueryExpression(final String query) {
final String fields = String.join(",", DISPLAY_NAME_KEY, ALL_TEXT_FIELD_NAME);
final FunctionExpr fullText = FunctionExpr.from("fulltext", ValueExpr.string(fields), ValueExpr.string(query), ValueExpr.string("AND"));
final FunctionExpr nGram = FunctionExpr.from("ngram", ValueExpr.string(fields), ValueExpr.string(query), ValueExpr.string("AND"));
final LogicalExpr fullTextOrNgram = LogicalExpr.or(new DynamicConstraintExpr(fullText), new DynamicConstraintExpr(nGram));
return new QueryExpr(fullTextOrNgram, Collections.emptySet());
}
Aggregations