|
|
@@ -6,7 +6,7 @@ import com.google.common.collect.ArrayListMultimap;
|
|
|
import com.google.common.collect.ListMultimap;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import org.elasticsearch.dsl.bean.AtomQuery;
|
|
|
-import org.elasticsearch.dsl.bean.SQLCondition;
|
|
|
+import org.elasticsearch.dsl.bean.SQLConditionx;
|
|
|
import org.elasticsearch.dsl.enums.SQLBoolOperator;
|
|
|
import org.elasticsearch.dsl.enums.SQLConditionType;
|
|
|
import org.elasticsearch.dsl.exception.ElasticSql2DslException;
|
|
|
@@ -30,7 +30,7 @@ public abstract class AbstractQueryConditionParser implements QueryParser {
|
|
|
}
|
|
|
|
|
|
protected BoolQueryBuilder parseQueryConditionExpr(SQLExpr conditionExpr, String queryAs, Object[] sqlArgs) {
|
|
|
- SQLCondition sqlCondition = recursiveParseQueryCondition(conditionExpr, queryAs, sqlArgs);
|
|
|
+ SQLConditionx sqlCondition = recursiveParseQueryCondition(conditionExpr, queryAs, sqlArgs);
|
|
|
SQLBoolOperator operator = sqlCondition.getOperator();
|
|
|
|
|
|
if (SQLConditionType.Atom == sqlCondition.getSQLConditionType()) {
|
|
|
@@ -39,7 +39,7 @@ public abstract class AbstractQueryConditionParser implements QueryParser {
|
|
|
return mergeAtomQuery(sqlCondition.getQueryList(), operator);
|
|
|
}
|
|
|
|
|
|
- private SQLCondition recursiveParseQueryCondition(SQLExpr conditionExpr, String queryAs, Object[] sqlArgs) {
|
|
|
+ private SQLConditionx recursiveParseQueryCondition(SQLExpr conditionExpr, String queryAs, Object[] sqlArgs) {
|
|
|
if (conditionExpr instanceof SQLBinaryOpExpr) {
|
|
|
SQLBinaryOpExpr binOpExpr = (SQLBinaryOpExpr) conditionExpr;
|
|
|
SQLBinaryOperator binOperator = binOpExpr.getOperator();
|
|
|
@@ -47,18 +47,18 @@ public abstract class AbstractQueryConditionParser implements QueryParser {
|
|
|
if (SQLBinaryOperator.BooleanAnd == binOperator || SQLBinaryOperator.BooleanOr == binOperator) {
|
|
|
SQLBoolOperator operator = SQLBinaryOperator.BooleanAnd == binOperator ? SQLBoolOperator.AND : SQLBoolOperator.OR;
|
|
|
|
|
|
- SQLCondition leftCondition = recursiveParseQueryCondition(binOpExpr.getLeft(), queryAs, sqlArgs);
|
|
|
- SQLCondition rightCondition = recursiveParseQueryCondition(binOpExpr.getRight(), queryAs, sqlArgs);
|
|
|
+ SQLConditionx leftCondition = recursiveParseQueryCondition(binOpExpr.getLeft(), queryAs, sqlArgs);
|
|
|
+ SQLConditionx rightCondition = recursiveParseQueryCondition(binOpExpr.getRight(), queryAs, sqlArgs);
|
|
|
|
|
|
List<AtomQuery> mergedQueryList = Lists.newArrayList();
|
|
|
combineQueryBuilder(mergedQueryList, leftCondition, operator);
|
|
|
combineQueryBuilder(mergedQueryList, rightCondition, operator);
|
|
|
|
|
|
- return new SQLCondition(mergedQueryList, operator);
|
|
|
+ return new SQLConditionx(mergedQueryList, operator);
|
|
|
}
|
|
|
}
|
|
|
else if(conditionExpr instanceof SQLNotExpr) {
|
|
|
- SQLCondition innerSqlCondition = recursiveParseQueryCondition(((SQLNotExpr) conditionExpr).getExpr(), queryAs, sqlArgs);
|
|
|
+ SQLConditionx innerSqlCondition = recursiveParseQueryCondition(((SQLNotExpr) conditionExpr).getExpr(), queryAs, sqlArgs);
|
|
|
|
|
|
SQLBoolOperator operator = innerSqlCondition.getOperator();
|
|
|
if(SQLConditionType.Atom == innerSqlCondition.getSQLConditionType()) {
|
|
|
@@ -68,10 +68,10 @@ public abstract class AbstractQueryConditionParser implements QueryParser {
|
|
|
BoolQueryBuilder boolQuery = mergeAtomQuery(innerSqlCondition.getQueryList(), operator);
|
|
|
boolQuery = QueryBuilders.boolQuery().mustNot(boolQuery);
|
|
|
|
|
|
- return new SQLCondition(new AtomQuery(boolQuery), SQLConditionType.Atom);
|
|
|
+ return new SQLConditionx(new AtomQuery(boolQuery), SQLConditionType.Atom);
|
|
|
}
|
|
|
|
|
|
- return new SQLCondition(parseAtomQueryCondition(conditionExpr, queryAs, sqlArgs), SQLConditionType.Atom);
|
|
|
+ return new SQLConditionx(parseAtomQueryCondition(conditionExpr, queryAs, sqlArgs), SQLConditionType.Atom);
|
|
|
}
|
|
|
|
|
|
private AtomQuery parseAtomQueryCondition(SQLExpr sqlConditionExpr, String queryAs, Object[] sqlArgs) {
|
|
|
@@ -94,7 +94,7 @@ public abstract class AbstractQueryConditionParser implements QueryParser {
|
|
|
throw new ElasticSql2DslException(String.format("[syntax error] Can not support query condition type[%s]", sqlConditionExpr.toString()));
|
|
|
}
|
|
|
|
|
|
- private void combineQueryBuilder(List<AtomQuery> combiner, SQLCondition sqlCondition, SQLBoolOperator binOperator) {
|
|
|
+ private void combineQueryBuilder(List<AtomQuery> combiner, SQLConditionx sqlCondition, SQLBoolOperator binOperator) {
|
|
|
if (SQLConditionType.Atom == sqlCondition.getSQLConditionType() || sqlCondition.getOperator() == binOperator) {
|
|
|
combiner.addAll(sqlCondition.getQueryList());
|
|
|
}
|