From 96e1498dbf6e04057748ae5755a89957ee0deda2 Mon Sep 17 00:00:00 2001 From: spuerx <465360798@qq.com> Date: Fri, 31 Mar 2017 23:31:57 +0800 Subject: [PATCH] x --- .../method/AbstractAtomMethodQueryParser.java | 8 +- ...bstractFieldSpecificMethodQueryParser.java | 75 +++++++++++++ ...stractFieldSpecifiedMethodQueryParser.java | 104 ------------------ .../method/CheckableMethodQueryParser.java | 11 +- .../parser/query/method/MethodInvocation.java | 27 +++++ .../query/method/MethodQueryParser.java | 6 +- .../ParameterizedMethodQueryParser.java | 57 ++++++++++ .../fulltext/FullTextAtomQueryParser.java | 6 +- .../method/fulltext/MatchAtomQueryParser.java | 6 + .../fulltext/MultiMatchAtomQueryParser.java | 6 + .../fulltext/QueryStringAtomQueryParser.java | 6 + .../SimpleQueryStringAtomQueryParser.java | 6 + .../method/script/ScriptAtomQueryParser.java | 8 +- .../method/term/FuzzyAtomQueryParser.java | 67 +++++------ .../method/term/PrefixAtomQueryParser.java | 81 +++++++------- .../method/term/RegexpAtomQueryParser.java | 80 +++++++------- .../method/term/TermAtomQueryParser.java | 82 +++++++------- .../method/term/TermLevelAtomQueryParser.java | 60 +++++----- .../method/term/TermsAtomQueryParser.java | 81 +++++++------- .../method/term/WildcardAtomQueryParser.java | 81 +++++++------- .../sql/AbstractQueryConditionParser.java | 33 +++--- .../query/SqlParserWhereConditionTest.java | 12 ++ ...elasticsearch.query.SqlParserLimitTest.xml | 8 +- ...sticsearch.query.SqlParserListenerTest.xml | 4 +- ...asticsearch.query.SqlParserOrderByTest.xml | 4 +- ...elasticsearch.query.SqlParserQueryTest.xml | 20 ++-- ...asticsearch.query.SqlParserRoutingTest.xml | 4 +- ...csearch.query.SqlParserSelectFieldTest.xml | 10 +- ...arch.query.SqlParserWhereConditionTest.xml | 15 +-- ...elasticsearch.query.SqlParserLimitTest.txt | 2 +- ...sticsearch.query.SqlParserListenerTest.txt | 2 +- ...asticsearch.query.SqlParserOrderByTest.txt | 2 +- ...elasticsearch.query.SqlParserQueryTest.txt | 2 +- ...asticsearch.query.SqlParserRoutingTest.txt | 2 +- ...csearch.query.SqlParserSelectFieldTest.txt | 2 +- ...arch.query.SqlParserWhereConditionTest.txt | 2 +- ...g.elasticsearch.jdbc.ElasticDriverTest.xml | 10 +- ...EST-org.elasticsearch.jdbc.GroupByTest.xml | 4 +- ...org.elasticsearch.jdbc.MethodQueryTest.xml | 4 +- ...org.elasticsearch.jdbc.ScriptQueryTest.xml | 4 +- ...g.elasticsearch.jdbc.ElasticDriverTest.txt | 2 +- .../org.elasticsearch.jdbc.GroupByTest.txt | 2 +- ...org.elasticsearch.jdbc.MethodQueryTest.txt | 2 +- ...org.elasticsearch.jdbc.ScriptQueryTest.txt | 2 +- 44 files changed, 566 insertions(+), 446 deletions(-) create mode 100644 elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/AbstractFieldSpecificMethodQueryParser.java delete mode 100644 elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/AbstractFieldSpecifiedMethodQueryParser.java create mode 100644 elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/MethodInvocation.java create mode 100644 elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/ParameterizedMethodQueryParser.java diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/AbstractAtomMethodQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/AbstractAtomMethodQueryParser.java index 190b02e..c6ecfb7 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/AbstractAtomMethodQueryParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/AbstractAtomMethodQueryParser.java @@ -13,7 +13,7 @@ import java.util.Map; -public abstract class AbstractAtomMethodQueryParser { +public abstract class AbstractAtomMethodQueryParser implements MethodQueryParser { protected static final String COMMA = ","; @@ -34,10 +34,10 @@ protected interface IConditionMethodQueryBuilder { } - public final AtomQuery parseAtomMethodQuery(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { - checkQueryMethod(methodQueryExpr, queryAs, sqlArgs); + public final AtomQuery parseAtomMethodQuery(MethodInvocation invocation) { + checkQueryMethod(invocation.getMatchQueryExpr(), invocation.getQueryAs(), invocation.getSqlArgs()); - return parseMethodQueryExpr(methodQueryExpr, queryAs, sqlArgs); + return parseMethodQueryExpr(invocation.getMatchQueryExpr(), invocation.getQueryAs(), invocation.getSqlArgs()); } protected AtomQuery parseCondition(SQLExpr queryFieldExpr, Object[] parameters, String queryAs, IConditionMethodQueryBuilder queryBuilder) { diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/AbstractFieldSpecificMethodQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/AbstractFieldSpecificMethodQueryParser.java new file mode 100644 index 0000000..f6af6b0 --- /dev/null +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/AbstractFieldSpecificMethodQueryParser.java @@ -0,0 +1,75 @@ +package org.elasticsearch.dsl.parser.query.method; + +import com.alibaba.druid.sql.ast.SQLExpr; +import org.elasticsearch.dsl.bean.AtomQuery; +import org.elasticsearch.dsl.bean.ElasticSqlQueryField; +import org.elasticsearch.dsl.enums.QueryFieldType; +import org.elasticsearch.dsl.exception.ElasticSql2DslException; +import org.elasticsearch.dsl.listener.ParseActionListener; +import org.elasticsearch.dsl.parser.sql.QueryFieldParser; +import org.elasticsearch.index.query.QueryBuilder; + +import java.util.Map; + +public abstract class AbstractFieldSpecificMethodQueryParser extends ParameterizedMethodQueryParser { + + protected ParseActionListener parseActionListener; + + public AbstractFieldSpecificMethodQueryParser(ParseActionListener parseActionListener) { + this.parseActionListener = parseActionListener; + } + + protected abstract QueryBuilder buildQuery(MethodInvocation invocation, String fieldName, Map extraParams); + + protected abstract SQLExpr getFieldExpr(MethodInvocation invocation); + + @Override + protected String getExtraParamString(MethodInvocation invocation) { + //ignore extra params, subclass can override if necessary + return null; + } + + @Override + protected AtomQuery parseMethodQueryWithExtraParams(MethodInvocation invocation, Map extraParamMap) throws ElasticSql2DslException { + return parseCondition(invocation, extraParamMap); + } + + private AtomQuery parseCondition(MethodInvocation invocation, Map extraParamMap) { + QueryFieldParser queryFieldParser = new QueryFieldParser(); + ElasticSqlQueryField queryField = queryFieldParser.parseConditionQueryField(getFieldExpr(invocation), invocation.getQueryAs()); + + AtomQuery atomQuery = null; + if (queryField.getQueryFieldType() == QueryFieldType.RootDocField || queryField.getQueryFieldType() == QueryFieldType.InnerDocField) { + QueryBuilder originalQuery = buildQuery(invocation, queryField.getQueryFieldFullName(), extraParamMap); + atomQuery = new AtomQuery(originalQuery); + } + + if (queryField.getQueryFieldType() == QueryFieldType.NestedDocField) { + QueryBuilder originalQuery = buildQuery(invocation, queryField.getQueryFieldFullName(), extraParamMap); + atomQuery = new AtomQuery(originalQuery, queryField.getNestedDocContextPath()); + } + + if (atomQuery == null) { + throw new ElasticSql2DslException(String.format("[syntax error] query condition field can not support type[%s]", queryField.getQueryFieldType())); + } + + onAtomMethodQueryConditionParse(queryField, invocation.getSqlArgs()); + + return atomQuery; + } + + + private void onAtomMethodQueryConditionParse(ElasticSqlQueryField paramName, Object[] parameters) { + try { + parseActionListener.onAtomMethodQueryConditionParse(paramName, parameters); + } + catch (Exception ex) { + try { + parseActionListener.onFailure(ex); + } + catch (Exception exp) { + //ignore; + } + } + } +} diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/AbstractFieldSpecifiedMethodQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/AbstractFieldSpecifiedMethodQueryParser.java deleted file mode 100644 index df46a67..0000000 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/AbstractFieldSpecifiedMethodQueryParser.java +++ /dev/null @@ -1,104 +0,0 @@ -//package org.elasticsearch.dsl.parser.query.method; -// -//import com.alibaba.druid.sql.ast.SQLExpr; -//import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr; -//import com.google.common.collect.Maps; -//import org.elasticsearch.dsl.bean.AtomQuery; -//import org.elasticsearch.dsl.bean.ElasticSqlQueryField; -//import org.elasticsearch.dsl.enums.QueryFieldType; -//import org.elasticsearch.dsl.exception.ElasticSql2DslException; -//import org.elasticsearch.dsl.listener.ParseActionListener; -//import org.elasticsearch.dsl.parser.sql.QueryFieldParser; -//import org.elasticsearch.index.query.QueryBuilder; -// -//import java.util.Map; -// -//public abstract class AbstractFieldSpecifiedMethodQueryParser extends CheckableMethodQueryParser { -// -// protected static final String COMMA = ","; -// -// protected static final String COLON = ":"; -// -// protected ParseActionListener parseActionListener; -// -// public AbstractFieldSpecifiedMethodQueryParser(ParseActionListener parseActionListener) { -// this.parseActionListener = parseActionListener; -// } -// -// protected abstract void checkQueryMethod(SQLMethodInvokeExpr matchQueryExpr, String queryAs, Object[] sqlArgs); -// -// protected abstract AtomQuery parseMethodQueryExpr(SQLMethodInvokeExpr matchQueryExpr, String queryAs, Object[] sqlArgs); -// -// protected interface IConditionMethodQueryBuilder { -// QueryBuilder buildQuery(String queryFieldName, Object[] parameters); -// } -// -// -// public final AtomQuery parseAtomMethodQuery(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { -// checkQueryMethod(methodQueryExpr, queryAs, sqlArgs); -// -// return parseMethodQueryExpr(methodQueryExpr, queryAs, sqlArgs); -// } -// -// protected AtomQuery parseCondition(SQLExpr queryFieldExpr, Object[] parameters, String queryAs, IConditionMethodQueryBuilder queryBuilder) { -// QueryFieldParser queryFieldParser = new QueryFieldParser(); -// ElasticSqlQueryField queryField = queryFieldParser.parseConditionQueryField(queryFieldExpr, queryAs); -// -// AtomQuery atomQuery = null; -// if (queryField.getQueryFieldType() == QueryFieldType.RootDocField || queryField.getQueryFieldType() == QueryFieldType.InnerDocField) { -// QueryBuilder originalQuery = queryBuilder.buildQuery(queryField.getQueryFieldFullName(), parameters); -// atomQuery = new AtomQuery(originalQuery); -// } -// -// if (queryField.getQueryFieldType() == QueryFieldType.NestedDocField) { -// QueryBuilder originalQuery = queryBuilder.buildQuery(queryField.getQueryFieldFullName(), parameters); -// atomQuery = new AtomQuery(originalQuery, queryField.getNestedDocContextPath()); -// } -// -// if (atomQuery == null) { -// throw new ElasticSql2DslException(String.format("[syntax error] query condition field can not support type[%s]", queryField.getQueryFieldType())); -// } -// -// onAtomMethodQueryConditionParse(queryField, parameters); -// -// return atomQuery; -// } -// -// private void onAtomMethodQueryConditionParse(ElasticSqlQueryField paramName, Object[] parameters) { -// try { -// parseActionListener.onAtomMethodQueryConditionParse(paramName, parameters); -// } -// catch (Exception ex) { -// try { -// parseActionListener.onFailure(ex); -// } -// catch (Exception exp) { -// //ignore; -// } -// } -// } -// -// protected Map buildExtraMethodQueryParamsMap(String strMatchQueryParams) { -// Map extraParamMap = Maps.newHashMap(); -// for (String paramPair : strMatchQueryParams.split(COMMA)) { -// String[] paramPairArr = paramPair.split(COLON); -// if (paramPairArr.length == 2) { -// extraParamMap.put(paramPairArr[0].trim(), paramPairArr[1].trim()); -// } -// else { -// throw new ElasticSql2DslException("Failed to parse query method params!"); -// } -// } -// return extraParamMap; -// } -// -// protected Boolean isExtraParamsString(String extraParams) { -// for (String paramPair : extraParams.split(COMMA)) { -// String[] paramPairArr = paramPair.split(COLON); -// if (paramPairArr.length != 2) { -// return Boolean.FALSE; -// } -// } -// return Boolean.TRUE; -// } -//} diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/CheckableMethodQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/CheckableMethodQueryParser.java index 505f79a..ec18afb 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/CheckableMethodQueryParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/CheckableMethodQueryParser.java @@ -1,18 +1,17 @@ package org.elasticsearch.dsl.parser.query.method; -import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr; import org.elasticsearch.dsl.bean.AtomQuery; import org.elasticsearch.dsl.exception.ElasticSql2DslException; public abstract class CheckableMethodQueryParser implements MethodQueryParser { - abstract void checkQueryMethod(SQLMethodInvokeExpr matchQueryExpr, String queryAs, Object[] sqlArgs); + protected abstract void checkQueryMethod(MethodInvocation invocation) throws ElasticSql2DslException; - abstract AtomQuery parseMethodQueryExpr(SQLMethodInvokeExpr matchQueryExpr, String queryAs, Object[] sqlArgs); + protected abstract AtomQuery parseMethodQueryWithCheck(MethodInvocation invocation) throws ElasticSql2DslException; @Override - public AtomQuery parseAtomMethodQuery(SQLMethodInvokeExpr methodExpr, String queryAs, Object[] sqlArgs) throws ElasticSql2DslException { - checkQueryMethod(methodExpr, queryAs, sqlArgs); - return parseMethodQueryExpr(methodExpr, queryAs, sqlArgs); + public AtomQuery parseAtomMethodQuery(MethodInvocation invocation) throws ElasticSql2DslException { + checkQueryMethod(invocation); + return parseMethodQueryWithCheck(invocation); } } diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/MethodInvocation.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/MethodInvocation.java new file mode 100644 index 0000000..51a3970 --- /dev/null +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/MethodInvocation.java @@ -0,0 +1,27 @@ +package org.elasticsearch.dsl.parser.query.method; + +import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr; + +public class MethodInvocation { + private SQLMethodInvokeExpr matchQueryExpr; + private String queryAs; + private Object[] sqlArgs; + + public MethodInvocation(SQLMethodInvokeExpr matchQueryExpr, String queryAs, Object[] sqlArgs) { + this.matchQueryExpr = matchQueryExpr; + this.queryAs = queryAs; + this.sqlArgs = sqlArgs; + } + + public SQLMethodInvokeExpr getMatchQueryExpr() { + return matchQueryExpr; + } + + public String getQueryAs() { + return queryAs; + } + + public Object[] getSqlArgs() { + return sqlArgs; + } +} diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/MethodQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/MethodQueryParser.java index 53d9086..08e8f77 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/MethodQueryParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/MethodQueryParser.java @@ -1,12 +1,10 @@ package org.elasticsearch.dsl.parser.query.method; -import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr; import org.elasticsearch.dsl.bean.AtomQuery; import org.elasticsearch.dsl.exception.ElasticSql2DslException; public interface MethodQueryParser { + boolean isMatchMethodInvocation(MethodInvocation invocation); - boolean isMethodOf(SQLMethodInvokeExpr methodExpr); - - AtomQuery parseAtomMethodQuery(SQLMethodInvokeExpr methodExpr, String queryAs, Object[] sqlArgs) throws ElasticSql2DslException; + AtomQuery parseAtomMethodQuery(MethodInvocation invocation) throws ElasticSql2DslException; } diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/ParameterizedMethodQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/ParameterizedMethodQueryParser.java new file mode 100644 index 0000000..c493b95 --- /dev/null +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/ParameterizedMethodQueryParser.java @@ -0,0 +1,57 @@ +package org.elasticsearch.dsl.parser.query.method; + +import com.google.common.collect.Maps; +import org.apache.commons.lang.StringUtils; +import org.elasticsearch.dsl.bean.AtomQuery; +import org.elasticsearch.dsl.exception.ElasticSql2DslException; + +import java.util.Collections; +import java.util.Map; + +public abstract class ParameterizedMethodQueryParser extends CheckableMethodQueryParser { + + private static final String COMMA = ","; + + private static final String COLON = ":"; + + protected abstract String getExtraParamString(MethodInvocation invocation); + + protected abstract AtomQuery parseMethodQueryWithExtraParams( + MethodInvocation invocation, Map extraParamMap) throws ElasticSql2DslException; + + @Override + protected AtomQuery parseMethodQueryWithCheck(MethodInvocation invocation) { + Map extraParamMap = buildExtraParamMap(invocation); + return parseMethodQueryWithExtraParams(invocation, extraParamMap); + } + + private Map buildExtraParamMap(MethodInvocation invocation) { + String extraParamString = getExtraParamString(invocation); + + if (StringUtils.isBlank(extraParamString)) { + return Collections.emptyMap(); + } + + Map extraParamMap = Maps.newHashMap(); + for (String paramPair : extraParamString.split(COMMA)) { + String[] paramPairArr = paramPair.split(COLON); + if (paramPairArr.length == 2) { + extraParamMap.put(paramPairArr[0].trim(), paramPairArr[1].trim()); + } + else { + throw new ElasticSql2DslException("Failed to parse query method extra param string!"); + } + } + return extraParamMap; + } + + protected Boolean isExtraParamsString(String extraParams) { + for (String paramPair : extraParams.split(COMMA)) { + String[] paramPairArr = paramPair.split(COLON); + if (paramPairArr.length != 2) { + return Boolean.FALSE; + } + } + return Boolean.TRUE; + } +} diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/FullTextAtomQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/FullTextAtomQueryParser.java index 4b36a00..d61baf7 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/FullTextAtomQueryParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/FullTextAtomQueryParser.java @@ -5,6 +5,7 @@ import org.elasticsearch.dsl.exception.ElasticSql2DslException; import org.elasticsearch.dsl.listener.ParseActionListener; import org.elasticsearch.dsl.parser.query.method.AbstractAtomMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.MethodInvocation; public class FullTextAtomQueryParser { @@ -14,14 +15,15 @@ public FullTextAtomQueryParser(ParseActionListener parseActionListener) { this.parseActionListener = parseActionListener; } - public static Boolean isFulltextAtomQuery(SQLMethodInvokeExpr methodQueryExpr) { + public Boolean isFulltextAtomQuery(SQLMethodInvokeExpr methodQueryExpr) { return MatchAtomQueryParser.isMatchQuery(methodQueryExpr) || MultiMatchAtomQueryParser.isMultiMatch(methodQueryExpr) || QueryStringAtomQueryParser.isQueryStringQuery(methodQueryExpr) || SimpleQueryStringAtomQueryParser.isSimpleQueryStringQuery(methodQueryExpr); } public AtomQuery parseFullTextAtomQuery(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { AbstractAtomMethodQueryParser matchAtomQueryParser = getQueryParser(methodQueryExpr); - return matchAtomQueryParser.parseAtomMethodQuery(methodQueryExpr, queryAs, sqlArgs); + MethodInvocation methodInvocation = new MethodInvocation(methodQueryExpr, queryAs, sqlArgs); + return matchAtomQueryParser.parseAtomMethodQuery(methodInvocation); } private AbstractAtomMethodQueryParser getQueryParser(SQLMethodInvokeExpr methodQueryExpr) { diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/MatchAtomQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/MatchAtomQueryParser.java index 323e064..8d8783b 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/MatchAtomQueryParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/MatchAtomQueryParser.java @@ -12,6 +12,7 @@ import org.elasticsearch.dsl.helper.ElasticSqlMethodInvokeHelper; import org.elasticsearch.dsl.listener.ParseActionListener; import org.elasticsearch.dsl.parser.query.method.AbstractAtomMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.MethodInvocation; import org.elasticsearch.index.query.MatchQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; @@ -31,6 +32,11 @@ public static Boolean isMatchQuery(SQLMethodInvokeExpr methodQueryExpr) { return ElasticSqlMethodInvokeHelper.isMethodOf(MATCH_METHOD, methodQueryExpr.getMethodName()); } + @Override + public boolean isMatchMethodInvocation(MethodInvocation invocation) { + return false; + } + @Override protected void checkQueryMethod(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { if (Boolean.FALSE == isMatchQuery(methodQueryExpr)) { diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/MultiMatchAtomQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/MultiMatchAtomQueryParser.java index 25b63f7..3104852 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/MultiMatchAtomQueryParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/MultiMatchAtomQueryParser.java @@ -12,6 +12,7 @@ import org.elasticsearch.dsl.helper.ElasticSqlMethodInvokeHelper; import org.elasticsearch.dsl.listener.ParseActionListener; import org.elasticsearch.dsl.parser.query.method.AbstractAtomMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.MethodInvocation; import org.elasticsearch.index.query.MatchQueryBuilder; import org.elasticsearch.index.query.MultiMatchQueryBuilder; import org.elasticsearch.index.query.QueryBuilders; @@ -31,6 +32,11 @@ public static Boolean isMultiMatch(SQLMethodInvokeExpr methodQueryExpr) { return ElasticSqlMethodInvokeHelper.isMethodOf(MULTI_MATCH_METHOD, methodQueryExpr.getMethodName()); } + @Override + public boolean isMatchMethodInvocation(MethodInvocation invocation) { + return false; + } + @Override protected void checkQueryMethod(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { if (Boolean.FALSE == isMultiMatch(methodQueryExpr)) { diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/QueryStringAtomQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/QueryStringAtomQueryParser.java index 9e9f6a1..f0459da 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/QueryStringAtomQueryParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/QueryStringAtomQueryParser.java @@ -12,6 +12,7 @@ import org.elasticsearch.dsl.helper.ElasticSqlMethodInvokeHelper; import org.elasticsearch.dsl.listener.ParseActionListener; import org.elasticsearch.dsl.parser.query.method.AbstractAtomMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.MethodInvocation; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryStringQueryBuilder; @@ -31,6 +32,11 @@ public static Boolean isQueryStringQuery(SQLMethodInvokeExpr methodQueryExpr) { return ElasticSqlMethodInvokeHelper.isMethodOf(QUERY_STRING_METHOD, methodQueryExpr.getMethodName()); } + @Override + public boolean isMatchMethodInvocation(MethodInvocation invocation) { + return false; + } + @Override protected void checkQueryMethod(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { if (Boolean.FALSE == isQueryStringQuery(methodQueryExpr)) { diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/SimpleQueryStringAtomQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/SimpleQueryStringAtomQueryParser.java index 88a8dae..44b4019 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/SimpleQueryStringAtomQueryParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/fulltext/SimpleQueryStringAtomQueryParser.java @@ -12,6 +12,7 @@ import org.elasticsearch.dsl.helper.ElasticSqlMethodInvokeHelper; import org.elasticsearch.dsl.listener.ParseActionListener; import org.elasticsearch.dsl.parser.query.method.AbstractAtomMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.MethodInvocation; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.SimpleQueryStringBuilder; import org.elasticsearch.index.query.SimpleQueryStringFlag; @@ -32,6 +33,11 @@ public static Boolean isSimpleQueryStringQuery(SQLMethodInvokeExpr methodQueryEx return ElasticSqlMethodInvokeHelper.isMethodOf(SIMPLE_QUERY_STRING_METHOD, methodQueryExpr.getMethodName()); } + @Override + public boolean isMatchMethodInvocation(MethodInvocation invocation) { + return false; + } + @Override protected void checkQueryMethod(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { if (Boolean.FALSE == isSimpleQueryStringQuery(methodQueryExpr)) { diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/script/ScriptAtomQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/script/ScriptAtomQueryParser.java index 6495f0b..83e3977 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/script/ScriptAtomQueryParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/script/ScriptAtomQueryParser.java @@ -12,6 +12,7 @@ import org.elasticsearch.dsl.helper.ElasticSqlMethodInvokeHelper; import org.elasticsearch.dsl.listener.ParseActionListener; import org.elasticsearch.dsl.parser.query.method.AbstractAtomMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.MethodInvocation; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptService; @@ -27,13 +28,14 @@ public ScriptAtomQueryParser(ParseActionListener parseActionListener) { super(parseActionListener); } - public static Boolean isScriptAtomQuery(SQLMethodInvokeExpr methodQueryExpr) { - return ElasticSqlMethodInvokeHelper.isMethodOf(SCRIPT_METHOD, methodQueryExpr.getMethodName()); + @Override + public boolean isMatchMethodInvocation(MethodInvocation invocation) { + return ElasticSqlMethodInvokeHelper.isMethodOf(SCRIPT_METHOD, invocation.getMatchQueryExpr().getMethodName()); } @Override protected void checkQueryMethod(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { - if (Boolean.FALSE == isScriptAtomQuery(methodQueryExpr)) { + if (Boolean.FALSE == isMatchMethodInvocation(new MethodInvocation(methodQueryExpr, queryAs, sqlArgs))) { throw new ElasticSql2DslException(String.format("[syntax error] Expected script query method name is [script],but get [%s]", methodQueryExpr.getMethodName())); } diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/FuzzyAtomQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/FuzzyAtomQueryParser.java index 63f1f3a..dbcbaea 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/FuzzyAtomQueryParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/FuzzyAtomQueryParser.java @@ -6,12 +6,12 @@ import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; import org.elasticsearch.common.unit.Fuzziness; -import org.elasticsearch.dsl.bean.AtomQuery; import org.elasticsearch.dsl.exception.ElasticSql2DslException; import org.elasticsearch.dsl.helper.ElasticSqlArgTransferHelper; import org.elasticsearch.dsl.helper.ElasticSqlMethodInvokeHelper; import org.elasticsearch.dsl.listener.ParseActionListener; -import org.elasticsearch.dsl.parser.query.method.AbstractAtomMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.AbstractFieldSpecificMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.MethodInvocation; import org.elasticsearch.index.query.FuzzyQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; @@ -19,7 +19,7 @@ import java.util.List; import java.util.Map; -public class FuzzyAtomQueryParser extends AbstractAtomMethodQueryParser { +public class FuzzyAtomQueryParser extends AbstractFieldSpecificMethodQueryParser { private static List FUZZY_QUERY_METHOD = ImmutableList.of("fuzzy", "fuzzy_query", "fuzzyQuery"); @@ -27,16 +27,22 @@ public FuzzyAtomQueryParser(ParseActionListener parseActionListener) { super(parseActionListener); } - public static Boolean isFuzzyQuery(SQLMethodInvokeExpr methodQueryExpr) { - return ElasticSqlMethodInvokeHelper.isMethodOf(FUZZY_QUERY_METHOD, methodQueryExpr.getMethodName()); + @Override + public boolean isMatchMethodInvocation(MethodInvocation invocation) { + return ElasticSqlMethodInvokeHelper.isMethodOf(FUZZY_QUERY_METHOD, invocation.getMatchQueryExpr().getMethodName()); } @Override - protected void checkQueryMethod(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { - if (Boolean.FALSE == isFuzzyQuery(methodQueryExpr)) { - throw new ElasticSql2DslException(String.format("[syntax error] Expected fuzzy query method name is [fuzzy],but get [%s]", methodQueryExpr.getMethodName())); + protected void checkQueryMethod(MethodInvocation invocation) { + + if (Boolean.FALSE == isMatchMethodInvocation(invocation)) { + throw new ElasticSql2DslException( + String.format("[syntax error] Expected fuzzy query method name is [fuzzy],but get [%s]", + invocation.getMatchQueryExpr().getMethodName())); } + SQLMethodInvokeExpr methodQueryExpr = invocation.getMatchQueryExpr(); + int paramCount = methodQueryExpr.getParameters().size(); if (paramCount != 2 && paramCount != 3) { throw new ElasticSql2DslException(String.format("[syntax error] There's no %s args method: fuzzy", paramCount)); @@ -44,41 +50,38 @@ protected void checkQueryMethod(SQLMethodInvokeExpr methodQueryExpr, String quer SQLExpr textExpr = methodQueryExpr.getParameters().get(1); - String text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, sqlArgs, false).toString(); + String text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, invocation.getSqlArgs(), false).toString(); if (StringUtils.isEmpty(text)) { throw new ElasticSql2DslException("[syntax error] Fuzzy text can not be blank!"); } } @Override - @SuppressWarnings("unchecked") - protected AtomQuery parseMethodQueryExpr(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { - SQLExpr queryField = methodQueryExpr.getParameters().get(0); - SQLExpr textExpr = methodQueryExpr.getParameters().get(1); - - Map extraParamMap = null; - if (methodQueryExpr.getParameters().size() == 3) { - SQLExpr ExtraParamExpr = methodQueryExpr.getParameters().get(2); - String extraParam = ElasticSqlArgTransferHelper.transferSqlArg(ExtraParamExpr, sqlArgs, false).toString(); - - extraParamMap = buildExtraMethodQueryParamsMap(extraParam); + protected String getExtraParamString(MethodInvocation invocation) { + SQLMethodInvokeExpr methodInvokeExpr = invocation.getMatchQueryExpr(); + if (methodInvokeExpr.getParameters().size() == 3) { + SQLExpr extraParamExpr = methodInvokeExpr.getParameters().get(2); + Object[] sqlArgs = invocation.getSqlArgs(); + return ElasticSqlArgTransferHelper.transferSqlArg(extraParamExpr, sqlArgs, false).toString(); } + return StringUtils.EMPTY; + } - Object text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, sqlArgs, false); + @Override + protected QueryBuilder buildQuery(MethodInvocation invocation, String fieldName, Map extraParams) { + SQLMethodInvokeExpr methodInvokeExpr = invocation.getMatchQueryExpr(); - return parseCondition(queryField, new Object[]{text, extraParamMap}, queryAs, new IConditionMethodQueryBuilder() { - @Override - public QueryBuilder buildQuery(String queryFieldName, Object[] parameters) { - FuzzyQueryBuilder fuzzyQuery = QueryBuilders.fuzzyQuery(queryFieldName, parameters[0].toString()); + SQLExpr textExpr = methodInvokeExpr.getParameters().get(1); + Object text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, invocation.getSqlArgs(), false); - if (parameters.length == 2 && parameters[1] != null) { - Map tExtraParamMap = (Map) parameters[1]; - setExtraMatchQueryParam(fuzzyQuery, tExtraParamMap); - } + FuzzyQueryBuilder fuzzyQuery = QueryBuilders.fuzzyQuery(fieldName, text); + setExtraMatchQueryParam(fuzzyQuery, extraParams); + return fuzzyQuery; + } - return fuzzyQuery; - } - }); + @Override + protected SQLExpr getFieldExpr(MethodInvocation invocation) { + return invocation.getMatchQueryExpr().getParameters().get(0); } private void setExtraMatchQueryParam(FuzzyQueryBuilder fuzzyQuery, Map extraParamMap) { diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/PrefixAtomQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/PrefixAtomQueryParser.java index e9df061..482421a 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/PrefixAtomQueryParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/PrefixAtomQueryParser.java @@ -5,12 +5,12 @@ import com.google.common.collect.ImmutableList; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; -import org.elasticsearch.dsl.bean.AtomQuery; import org.elasticsearch.dsl.exception.ElasticSql2DslException; import org.elasticsearch.dsl.helper.ElasticSqlArgTransferHelper; import org.elasticsearch.dsl.helper.ElasticSqlMethodInvokeHelper; import org.elasticsearch.dsl.listener.ParseActionListener; -import org.elasticsearch.dsl.parser.query.method.AbstractAtomMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.AbstractFieldSpecificMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.MethodInvocation; import org.elasticsearch.index.query.PrefixQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; @@ -18,7 +18,7 @@ import java.util.List; import java.util.Map; -public class PrefixAtomQueryParser extends AbstractAtomMethodQueryParser { +public class PrefixAtomQueryParser extends AbstractFieldSpecificMethodQueryParser { private static List PREFIX_QUERY_METHOD = ImmutableList.of("prefix", "prefix_query", "prefixQuery"); @@ -26,58 +26,61 @@ public PrefixAtomQueryParser(ParseActionListener parseActionListener) { super(parseActionListener); } - public static Boolean isPrefixQuery(SQLMethodInvokeExpr methodQueryExpr) { - return ElasticSqlMethodInvokeHelper.isMethodOf(PREFIX_QUERY_METHOD, methodQueryExpr.getMethodName()); + @Override + public boolean isMatchMethodInvocation(MethodInvocation invocation) { + return ElasticSqlMethodInvokeHelper.isMethodOf(PREFIX_QUERY_METHOD, invocation.getMatchQueryExpr().getMethodName()); } @Override - protected void checkQueryMethod(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { - if (Boolean.FALSE == isPrefixQuery(methodQueryExpr)) { - throw new ElasticSql2DslException(String.format("[syntax error] Expected prefix query method name is [prefix],but get [%s]", methodQueryExpr.getMethodName())); + protected String getExtraParamString(MethodInvocation invocation) { + SQLMethodInvokeExpr methodInvokeExpr = invocation.getMatchQueryExpr(); + if (methodInvokeExpr.getParameters().size() == 3) { + SQLExpr extraParamExpr = methodInvokeExpr.getParameters().get(2); + Object[] sqlArgs = invocation.getSqlArgs(); + return ElasticSqlArgTransferHelper.transferSqlArg(extraParamExpr, sqlArgs, false).toString(); } + return StringUtils.EMPTY; + } - int paramCount = methodQueryExpr.getParameters().size(); - if (paramCount != 2 && paramCount != 3) { - throw new ElasticSql2DslException(String.format("[syntax error] There's no %s args method: match", paramCount)); - } + @Override + protected QueryBuilder buildQuery(MethodInvocation invocation, String fieldName, Map extraParams) { + SQLMethodInvokeExpr methodInvokeExpr = invocation.getMatchQueryExpr(); - SQLExpr textExpr = methodQueryExpr.getParameters().get(1); + SQLExpr textExpr = methodInvokeExpr.getParameters().get(1); + Object text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, invocation.getSqlArgs(), false); - String text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, sqlArgs, false).toString(); - if (StringUtils.isEmpty(text)) { - throw new ElasticSql2DslException("[syntax error] Prefix text can not be blank!"); - } + PrefixQueryBuilder prefixQuery = QueryBuilders.prefixQuery(fieldName, text.toString()); + + setExtraMatchQueryParam(prefixQuery, extraParams); + return prefixQuery; } @Override - @SuppressWarnings("unchecked") - protected AtomQuery parseMethodQueryExpr(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { - SQLExpr queryField = methodQueryExpr.getParameters().get(0); - SQLExpr textExpr = methodQueryExpr.getParameters().get(1); - - Map extraParamMap = null; - if (methodQueryExpr.getParameters().size() == 3) { - SQLExpr ExtraParamExpr = methodQueryExpr.getParameters().get(2); - String extraParam = ElasticSqlArgTransferHelper.transferSqlArg(ExtraParamExpr, sqlArgs, false).toString(); + protected SQLExpr getFieldExpr(MethodInvocation invocation) { + return invocation.getMatchQueryExpr().getParameters().get(0); + } - extraParamMap = buildExtraMethodQueryParamsMap(extraParam); + @Override + protected void checkQueryMethod(MethodInvocation invocation) { + if (Boolean.FALSE == isMatchMethodInvocation(invocation)) { + throw new ElasticSql2DslException( + String.format("[syntax error] Expected prefix query method name is [prefix],but get [%s]", + invocation.getMatchQueryExpr().getMethodName())); } - Object text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, sqlArgs, false); + SQLMethodInvokeExpr methodQueryExpr = invocation.getMatchQueryExpr(); - return parseCondition(queryField, new Object[]{text, extraParamMap}, queryAs, new IConditionMethodQueryBuilder() { - @Override - public QueryBuilder buildQuery(String queryFieldName, Object[] parameters) { - PrefixQueryBuilder prefixQuery = QueryBuilders.prefixQuery(queryFieldName, parameters[0].toString()); + int paramCount = methodQueryExpr.getParameters().size(); + if (paramCount != 2 && paramCount != 3) { + throw new ElasticSql2DslException(String.format("[syntax error] There's no %s args method: match", paramCount)); + } - if (parameters.length == 2 && parameters[1] != null) { - Map tExtraParamMap = (Map) parameters[1]; - setExtraMatchQueryParam(prefixQuery, tExtraParamMap); - } + SQLExpr textExpr = methodQueryExpr.getParameters().get(1); - return prefixQuery; - } - }); + String text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, invocation.getSqlArgs(), false).toString(); + if (StringUtils.isEmpty(text)) { + throw new ElasticSql2DslException("[syntax error] Prefix text can not be blank!"); + } } private void setExtraMatchQueryParam(PrefixQueryBuilder prefixQuery, Map extraParamMap) { diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/RegexpAtomQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/RegexpAtomQueryParser.java index 9e8c33a..81ec8ad 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/RegexpAtomQueryParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/RegexpAtomQueryParser.java @@ -6,12 +6,12 @@ import com.google.common.collect.Lists; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; -import org.elasticsearch.dsl.bean.AtomQuery; import org.elasticsearch.dsl.exception.ElasticSql2DslException; import org.elasticsearch.dsl.helper.ElasticSqlArgTransferHelper; import org.elasticsearch.dsl.helper.ElasticSqlMethodInvokeHelper; import org.elasticsearch.dsl.listener.ParseActionListener; -import org.elasticsearch.dsl.parser.query.method.AbstractAtomMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.AbstractFieldSpecificMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.MethodInvocation; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.RegexpFlag; @@ -20,7 +20,7 @@ import java.util.List; import java.util.Map; -public class RegexpAtomQueryParser extends AbstractAtomMethodQueryParser { +public class RegexpAtomQueryParser extends AbstractFieldSpecificMethodQueryParser { private static List REGEXP_QUERY_METHOD = ImmutableList.of("regexp", "regexp_query", "regexpQuery"); @@ -28,58 +28,60 @@ public RegexpAtomQueryParser(ParseActionListener parseActionListener) { super(parseActionListener); } - public static Boolean isRegexpQuery(SQLMethodInvokeExpr methodQueryExpr) { - return ElasticSqlMethodInvokeHelper.isMethodOf(REGEXP_QUERY_METHOD, methodQueryExpr.getMethodName()); + @Override + public boolean isMatchMethodInvocation(MethodInvocation invocation) { + return ElasticSqlMethodInvokeHelper.isMethodOf(REGEXP_QUERY_METHOD, invocation.getMatchQueryExpr().getMethodName()); } @Override - protected void checkQueryMethod(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { - if (Boolean.FALSE == isRegexpQuery(methodQueryExpr)) { - throw new ElasticSql2DslException(String.format("[syntax error] Expected regexp query method name is [regexp],but get [%s]", methodQueryExpr.getMethodName())); + protected String getExtraParamString(MethodInvocation invocation) { + SQLMethodInvokeExpr methodInvokeExpr = invocation.getMatchQueryExpr(); + if (methodInvokeExpr.getParameters().size() == 3) { + SQLExpr extraParamExpr = methodInvokeExpr.getParameters().get(2); + Object[] sqlArgs = invocation.getSqlArgs(); + return ElasticSqlArgTransferHelper.transferSqlArg(extraParamExpr, sqlArgs, false).toString(); } + return StringUtils.EMPTY; + } - int paramCount = methodQueryExpr.getParameters().size(); - if (paramCount != 2 && paramCount != 3) { - throw new ElasticSql2DslException(String.format("[syntax error] There's no %s args method: regexp", paramCount)); - } + @Override + protected QueryBuilder buildQuery(MethodInvocation invocation, String fieldName, Map extraParams) { + SQLMethodInvokeExpr methodInvokeExpr = invocation.getMatchQueryExpr(); - SQLExpr textExpr = methodQueryExpr.getParameters().get(1); + SQLExpr textExpr = methodInvokeExpr.getParameters().get(1); + Object text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, invocation.getSqlArgs(), false); - String text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, sqlArgs, false).toString(); - if (StringUtils.isEmpty(text)) { - throw new ElasticSql2DslException("[syntax error] Regexp text can not be blank!"); - } + RegexpQueryBuilder regexpQuery = QueryBuilders.regexpQuery(fieldName, text.toString()); + setExtraMatchQueryParam(regexpQuery, extraParams); + return regexpQuery; } @Override - @SuppressWarnings("unchecked") - protected AtomQuery parseMethodQueryExpr(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { - SQLExpr queryField = methodQueryExpr.getParameters().get(0); - SQLExpr textExpr = methodQueryExpr.getParameters().get(1); - - Map extraParamMap = null; - if (methodQueryExpr.getParameters().size() == 3) { - SQLExpr ExtraParamExpr = methodQueryExpr.getParameters().get(2); - String extraParam = ElasticSqlArgTransferHelper.transferSqlArg(ExtraParamExpr, sqlArgs, false).toString(); + protected SQLExpr getFieldExpr(MethodInvocation invocation) { + return invocation.getMatchQueryExpr().getParameters().get(0); + } - extraParamMap = buildExtraMethodQueryParamsMap(extraParam); + @Override + protected void checkQueryMethod(MethodInvocation invocation) throws ElasticSql2DslException { + if (Boolean.FALSE == isMatchMethodInvocation(invocation)) { + throw new ElasticSql2DslException( + String.format("[syntax error] Expected regexp query method name is [regexp],but get [%s]", + invocation.getMatchQueryExpr().getMethodName())); } - Object text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, sqlArgs, false); + SQLMethodInvokeExpr methodQueryExpr = invocation.getMatchQueryExpr(); - return parseCondition(queryField, new Object[]{text, extraParamMap}, queryAs, new IConditionMethodQueryBuilder() { - @Override - public QueryBuilder buildQuery(String queryFieldName, Object[] parameters) { - RegexpQueryBuilder regexpQuery = QueryBuilders.regexpQuery(queryFieldName, parameters[0].toString()); + int paramCount = methodQueryExpr.getParameters().size(); + if (paramCount != 2 && paramCount != 3) { + throw new ElasticSql2DslException(String.format("[syntax error] There's no %s args method: regexp", paramCount)); + } - if (parameters.length == 2 && parameters[1] != null) { - Map tExtraParamMap = (Map) parameters[1]; - setExtraMatchQueryParam(regexpQuery, tExtraParamMap); - } + SQLExpr textExpr = methodQueryExpr.getParameters().get(1); - return regexpQuery; - } - }); + String text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, invocation.getSqlArgs(), false).toString(); + if (StringUtils.isEmpty(text)) { + throw new ElasticSql2DslException("[syntax error] Regexp text can not be blank!"); + } } private void setExtraMatchQueryParam(RegexpQueryBuilder regexpQuery, Map extraParamMap) { diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/TermAtomQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/TermAtomQueryParser.java index b9fafbb..0e471ec 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/TermAtomQueryParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/TermAtomQueryParser.java @@ -5,12 +5,12 @@ import com.google.common.collect.ImmutableList; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; -import org.elasticsearch.dsl.bean.AtomQuery; import org.elasticsearch.dsl.exception.ElasticSql2DslException; import org.elasticsearch.dsl.helper.ElasticSqlArgTransferHelper; import org.elasticsearch.dsl.helper.ElasticSqlMethodInvokeHelper; import org.elasticsearch.dsl.listener.ParseActionListener; -import org.elasticsearch.dsl.parser.query.method.AbstractAtomMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.AbstractFieldSpecificMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.MethodInvocation; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.TermQueryBuilder; @@ -18,7 +18,7 @@ import java.util.List; import java.util.Map; -public class TermAtomQueryParser extends AbstractAtomMethodQueryParser { +public class TermAtomQueryParser extends AbstractFieldSpecificMethodQueryParser { private static List TERM_QUERY_METHOD = ImmutableList.of("term", "term_query", "termQuery"); @@ -26,60 +26,64 @@ public TermAtomQueryParser(ParseActionListener parseActionListener) { super(parseActionListener); } - public static Boolean isTermQuery(SQLMethodInvokeExpr methodQueryExpr) { - return ElasticSqlMethodInvokeHelper.isMethodOf(TERM_QUERY_METHOD, methodQueryExpr.getMethodName()); + @Override + public boolean isMatchMethodInvocation(MethodInvocation invocation) { + return ElasticSqlMethodInvokeHelper.isMethodOf(TERM_QUERY_METHOD, invocation.getMatchQueryExpr().getMethodName()); } @Override - protected void checkQueryMethod(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { - if (Boolean.FALSE == isTermQuery(methodQueryExpr)) { - throw new ElasticSql2DslException(String.format("[syntax error] Expected term query method name is [term],but get [%s]", methodQueryExpr.getMethodName())); + protected String getExtraParamString(MethodInvocation invocation) { + SQLMethodInvokeExpr methodInvokeExpr = invocation.getMatchQueryExpr(); + if (methodInvokeExpr.getParameters().size() == 3) { + SQLExpr extraParamExpr = methodInvokeExpr.getParameters().get(2); + Object[] sqlArgs = invocation.getSqlArgs(); + return ElasticSqlArgTransferHelper.transferSqlArg(extraParamExpr, sqlArgs, false).toString(); } + return StringUtils.EMPTY; + } - int paramCount = methodQueryExpr.getParameters().size(); - if (paramCount != 2 && paramCount != 3) { - throw new ElasticSql2DslException(String.format("[syntax error] There's no %s args method: term", paramCount)); - } + @Override + protected QueryBuilder buildQuery(MethodInvocation invocation, String fieldName, Map extraParams) { + SQLMethodInvokeExpr methodInvokeExpr = invocation.getMatchQueryExpr(); - SQLExpr textExpr = methodQueryExpr.getParameters().get(1); + SQLExpr textExpr = methodInvokeExpr.getParameters().get(1); + Object text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, invocation.getSqlArgs(), false); - String text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, sqlArgs, false).toString(); - if (StringUtils.isEmpty(text)) { - throw new ElasticSql2DslException("[syntax error] Term text can not be blank!"); - } + TermQueryBuilder termQuery = QueryBuilders.termQuery(fieldName, text); + setExtraMatchQueryParam(termQuery, extraParams); + + return termQuery; } @Override - @SuppressWarnings("unchecked") - protected AtomQuery parseMethodQueryExpr(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { - SQLExpr queryField = methodQueryExpr.getParameters().get(0); - SQLExpr textExpr = methodQueryExpr.getParameters().get(1); - - Map extraParamMap = null; - if (methodQueryExpr.getParameters().size() == 3) { - SQLExpr ExtraParamExpr = methodQueryExpr.getParameters().get(2); - String extraParam = ElasticSqlArgTransferHelper.transferSqlArg(ExtraParamExpr, sqlArgs, false).toString(); + protected SQLExpr getFieldExpr(MethodInvocation invocation) { + return invocation.getMatchQueryExpr().getParameters().get(0); + } - extraParamMap = buildExtraMethodQueryParamsMap(extraParam); + @Override + protected void checkQueryMethod(MethodInvocation invocation) throws ElasticSql2DslException { + if (!isMatchMethodInvocation(invocation)) { + throw new ElasticSql2DslException( + String.format("[syntax error] Expected term query method name is [term],but get [%s]", + invocation.getMatchQueryExpr().getMethodName())); } - Object text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, sqlArgs, false); + SQLMethodInvokeExpr methodCallExpr = invocation.getMatchQueryExpr(); - return parseCondition(queryField, new Object[]{text, extraParamMap}, queryAs, new IConditionMethodQueryBuilder() { - @Override - public QueryBuilder buildQuery(String queryFieldName, Object[] parameters) { - TermQueryBuilder termQuery = QueryBuilders.termQuery(queryFieldName, parameters[0].toString()); + int paramCount = methodCallExpr.getParameters().size(); + if (paramCount != 2 && paramCount != 3) { + throw new ElasticSql2DslException(String.format("[syntax error] There's no %s args method: term", paramCount)); + } - if (parameters.length == 2 && parameters[1] != null) { - Map tExtraParamMap = (Map) parameters[1]; - setExtraMatchQueryParam(termQuery, tExtraParamMap); - } + SQLExpr textExpr = methodCallExpr.getParameters().get(1); - return termQuery; - } - }); + String text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, invocation.getSqlArgs(), false).toString(); + if (StringUtils.isEmpty(text)) { + throw new ElasticSql2DslException("[syntax error] Term text can not be blank!"); + } } + private void setExtraMatchQueryParam(TermQueryBuilder termQuery, Map extraParamMap) { if (MapUtils.isEmpty(extraParamMap)) { return; diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/TermLevelAtomQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/TermLevelAtomQueryParser.java index 02787a9..49155b6 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/TermLevelAtomQueryParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/TermLevelAtomQueryParser.java @@ -1,49 +1,53 @@ package org.elasticsearch.dsl.parser.query.method.term; import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr; +import com.google.common.collect.ImmutableList; import org.elasticsearch.dsl.bean.AtomQuery; import org.elasticsearch.dsl.exception.ElasticSql2DslException; import org.elasticsearch.dsl.listener.ParseActionListener; -import org.elasticsearch.dsl.parser.query.method.AbstractAtomMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.MethodInvocation; +import org.elasticsearch.dsl.parser.query.method.MethodQueryParser; + +import java.util.List; public class TermLevelAtomQueryParser { - protected ParseActionListener parseActionListener; + private final List methodQueryParsers; public TermLevelAtomQueryParser(ParseActionListener parseActionListener) { - this.parseActionListener = parseActionListener; + methodQueryParsers = ImmutableList.of( + new PrefixAtomQueryParser(parseActionListener), + new TermAtomQueryParser(parseActionListener), + new TermsAtomQueryParser(parseActionListener), + new WildcardAtomQueryParser(parseActionListener), + new RegexpAtomQueryParser(parseActionListener), + new FuzzyAtomQueryParser(parseActionListener) + ); } - public static Boolean isTermLevelAtomQuery(SQLMethodInvokeExpr methodQueryExpr) { - return PrefixAtomQueryParser.isPrefixQuery(methodQueryExpr) || TermAtomQueryParser.isTermQuery(methodQueryExpr) || - TermsAtomQueryParser.isTermsQuery(methodQueryExpr) || WildcardAtomQueryParser.isWildcardQuery(methodQueryExpr) || - RegexpAtomQueryParser.isRegexpQuery(methodQueryExpr) || FuzzyAtomQueryParser.isFuzzyQuery(methodQueryExpr); + public Boolean isTermLevelAtomQuery(MethodInvocation invocation) { + for (MethodQueryParser methodQueryParserItem : methodQueryParsers) { + if (methodQueryParserItem.isMatchMethodInvocation(invocation)) { + return Boolean.TRUE; + } + } + return Boolean.TRUE; } public AtomQuery parseTermLevelAtomQuery(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { - AbstractAtomMethodQueryParser matchAtomQueryParser = getQueryParser(methodQueryExpr); - return matchAtomQueryParser.parseAtomMethodQuery(methodQueryExpr, queryAs, sqlArgs); + MethodInvocation methodInvocation = new MethodInvocation(methodQueryExpr, queryAs, sqlArgs); + MethodQueryParser matchAtomQueryParser = getQueryParser(methodInvocation); + return matchAtomQueryParser.parseAtomMethodQuery(methodInvocation); } - private AbstractAtomMethodQueryParser getQueryParser(SQLMethodInvokeExpr methodQueryExpr) { - if (Boolean.TRUE == PrefixAtomQueryParser.isPrefixQuery(methodQueryExpr)) { - return new PrefixAtomQueryParser(parseActionListener); - } - if (Boolean.TRUE == TermAtomQueryParser.isTermQuery(methodQueryExpr)) { - return new TermAtomQueryParser(parseActionListener); - } - if (Boolean.TRUE == TermsAtomQueryParser.isTermsQuery(methodQueryExpr)) { - return new TermsAtomQueryParser(parseActionListener); - } - if (Boolean.TRUE == WildcardAtomQueryParser.isWildcardQuery(methodQueryExpr)) { - return new WildcardAtomQueryParser(parseActionListener); - } - if (Boolean.TRUE == RegexpAtomQueryParser.isRegexpQuery(methodQueryExpr)) { - return new RegexpAtomQueryParser(parseActionListener); - } - if (Boolean.TRUE == FuzzyAtomQueryParser.isFuzzyQuery(methodQueryExpr)) { - return new FuzzyAtomQueryParser(parseActionListener); + private MethodQueryParser getQueryParser(MethodInvocation methodInvocation) { + for (MethodQueryParser methodQueryParserItem : methodQueryParsers) { + if (methodQueryParserItem.isMatchMethodInvocation(methodInvocation)) { + return methodQueryParserItem; + } } - throw new ElasticSql2DslException(String.format("[syntax error] Can not support method query expr[%s] condition", methodQueryExpr.getMethodName())); + throw new ElasticSql2DslException( + String.format("[syntax error] Can not support method query expr[%s] condition", + methodInvocation.getMatchQueryExpr().getMethodName())); } } diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/TermsAtomQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/TermsAtomQueryParser.java index 3c23ed2..f44ca6b 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/TermsAtomQueryParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/TermsAtomQueryParser.java @@ -6,12 +6,12 @@ import com.google.common.collect.Lists; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; -import org.elasticsearch.dsl.bean.AtomQuery; import org.elasticsearch.dsl.exception.ElasticSql2DslException; import org.elasticsearch.dsl.helper.ElasticSqlArgTransferHelper; import org.elasticsearch.dsl.helper.ElasticSqlMethodInvokeHelper; import org.elasticsearch.dsl.listener.ParseActionListener; -import org.elasticsearch.dsl.parser.query.method.AbstractAtomMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.AbstractFieldSpecificMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.MethodInvocation; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.TermsQueryBuilder; @@ -19,7 +19,7 @@ import java.util.List; import java.util.Map; -public class TermsAtomQueryParser extends AbstractAtomMethodQueryParser { +public class TermsAtomQueryParser extends AbstractFieldSpecificMethodQueryParser { private static List TERMS_QUERY_METHOD = ImmutableList.of("terms", "terms_query", "termsQuery"); @@ -27,17 +27,35 @@ public TermsAtomQueryParser(ParseActionListener parseActionListener) { super(parseActionListener); } - public static Boolean isTermsQuery(SQLMethodInvokeExpr methodQueryExpr) { - return ElasticSqlMethodInvokeHelper.isMethodOf(TERMS_QUERY_METHOD, methodQueryExpr.getMethodName()); + @Override + public boolean isMatchMethodInvocation(MethodInvocation invocation) { + return ElasticSqlMethodInvokeHelper.isMethodOf(TERMS_QUERY_METHOD, invocation.getMatchQueryExpr().getMethodName()); } @Override - protected void checkQueryMethod(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { - if (Boolean.FALSE == isTermsQuery(methodQueryExpr)) { - throw new ElasticSql2DslException(String.format("[syntax error] Expected terms query method name is [terms],but get [%s]", methodQueryExpr.getMethodName())); + protected String getExtraParamString(MethodInvocation invocation) { + int paramCount = invocation.getMatchQueryExpr().getParameters().size(); + SQLExpr lastParam = invocation.getMatchQueryExpr().getParameters().get(paramCount - 1); + + String extraParamString = ElasticSqlArgTransferHelper.transferSqlArg(lastParam, invocation.getSqlArgs(), false).toString(); + + if (isExtraParamsString(extraParamString)) { + return extraParamString; } + return StringUtils.EMPTY; + } - int paramCount = methodQueryExpr.getParameters().size(); + @Override + protected void checkQueryMethod(MethodInvocation invocation) { + if (Boolean.FALSE == isMatchMethodInvocation(invocation)) { + throw new ElasticSql2DslException( + String.format("[syntax error] Expected terms query method name is [terms],but get [%s]", + invocation.getMatchQueryExpr().getMethodName())); + } + + SQLMethodInvokeExpr methodQueryExpr = invocation.getMatchQueryExpr(); + + int paramCount = invocation.getMatchQueryExpr().getParameters().size(); if (paramCount <= 1) { throw new ElasticSql2DslException(String.format("[syntax error] There's no %s args method: term", paramCount)); } @@ -45,24 +63,19 @@ protected void checkQueryMethod(SQLMethodInvokeExpr methodQueryExpr, String quer for (int idx = 1; idx < paramCount - 1; idx++) { SQLExpr textExpr = methodQueryExpr.getParameters().get(idx); - String text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, sqlArgs, false).toString(); + String text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, invocation.getSqlArgs(), false).toString(); if (StringUtils.isEmpty(text)) { throw new ElasticSql2DslException("[syntax error] Terms text can not be blank!"); } } - - SQLExpr lastParam = methodQueryExpr.getParameters().get(paramCount - 1); - String lastParamText = ElasticSqlArgTransferHelper.transferSqlArg(lastParam, sqlArgs, false).toString(); - - if (Boolean.FALSE == isExtraParamsString(lastParamText) && StringUtils.isEmpty(lastParamText)) { - throw new ElasticSql2DslException("[syntax error] Terms text can not be blank!"); - } } @Override - @SuppressWarnings("unchecked") - protected AtomQuery parseMethodQueryExpr(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { - SQLExpr queryField = methodQueryExpr.getParameters().get(0); + protected QueryBuilder buildQuery(MethodInvocation invocation, String fieldName, Map extraParams) { + + SQLMethodInvokeExpr methodQueryExpr = invocation.getMatchQueryExpr(); + Object[] sqlArgs = invocation.getSqlArgs(); + int paramCount = methodQueryExpr.getParameters().size(); List termTextList = Lists.newArrayList(); @@ -76,30 +89,18 @@ protected AtomQuery parseMethodQueryExpr(SQLMethodInvokeExpr methodQueryExpr, St SQLExpr lastParam = methodQueryExpr.getParameters().get(paramCount - 1); String lastParamText = ElasticSqlArgTransferHelper.transferSqlArg(lastParam, sqlArgs, false).toString(); - Map extraParamMap = null; - if (isExtraParamsString(lastParamText)) { - String extraParam = ElasticSqlArgTransferHelper.transferSqlArg(lastParam, sqlArgs, false).toString(); - - extraParamMap = buildExtraMethodQueryParamsMap(extraParam); - } - else { + if (Boolean.FALSE == isExtraParamsString(lastParamText)) { termTextList.add(lastParamText); } + TermsQueryBuilder termsQuery = QueryBuilders.termsQuery(fieldName, termTextList); + setExtraMatchQueryParam(termsQuery, extraParams); + return termsQuery; + } - return parseCondition(queryField, new Object[]{termTextList, extraParamMap}, queryAs, new IConditionMethodQueryBuilder() { - @Override - public QueryBuilder buildQuery(String queryFieldName, Object[] parameters) { - TermsQueryBuilder termsQuery = QueryBuilders.termsQuery(queryFieldName, (List) parameters[0]); - - if (parameters.length == 2 && parameters[1] != null) { - Map tExtraParamMap = (Map) parameters[1]; - setExtraMatchQueryParam(termsQuery, tExtraParamMap); - } - - return termsQuery; - } - }); + @Override + protected SQLExpr getFieldExpr(MethodInvocation invocation) { + return invocation.getMatchQueryExpr().getParameters().get(0); } private void setExtraMatchQueryParam(TermsQueryBuilder termsQuery, Map extraParamMap) { diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/WildcardAtomQueryParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/WildcardAtomQueryParser.java index 6aefd61..cb3eebf 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/WildcardAtomQueryParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/term/WildcardAtomQueryParser.java @@ -5,12 +5,12 @@ import com.google.common.collect.ImmutableList; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; -import org.elasticsearch.dsl.bean.AtomQuery; import org.elasticsearch.dsl.exception.ElasticSql2DslException; import org.elasticsearch.dsl.helper.ElasticSqlArgTransferHelper; import org.elasticsearch.dsl.helper.ElasticSqlMethodInvokeHelper; import org.elasticsearch.dsl.listener.ParseActionListener; -import org.elasticsearch.dsl.parser.query.method.AbstractAtomMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.AbstractFieldSpecificMethodQueryParser; +import org.elasticsearch.dsl.parser.query.method.MethodInvocation; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.WildcardQueryBuilder; @@ -18,7 +18,7 @@ import java.util.List; import java.util.Map; -public class WildcardAtomQueryParser extends AbstractAtomMethodQueryParser { +public class WildcardAtomQueryParser extends AbstractFieldSpecificMethodQueryParser { private static List WILDCARD_QUERY_METHOD = ImmutableList.of("wildcard", "wildcard_query", "wildcardQuery"); @@ -26,58 +26,61 @@ public WildcardAtomQueryParser(ParseActionListener parseActionListener) { super(parseActionListener); } - public static Boolean isWildcardQuery(SQLMethodInvokeExpr methodQueryExpr) { - return ElasticSqlMethodInvokeHelper.isMethodOf(WILDCARD_QUERY_METHOD, methodQueryExpr.getMethodName()); + + @Override + public boolean isMatchMethodInvocation(MethodInvocation invocation) { + return ElasticSqlMethodInvokeHelper.isMethodOf(WILDCARD_QUERY_METHOD, invocation.getMatchQueryExpr().getMethodName()); } @Override - protected void checkQueryMethod(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { - if (Boolean.FALSE == isWildcardQuery(methodQueryExpr)) { - throw new ElasticSql2DslException(String.format("[syntax error] Expected wildcard query method name is [wildcard],but get [%s]", methodQueryExpr.getMethodName())); + protected String getExtraParamString(MethodInvocation invocation) { + SQLMethodInvokeExpr methodInvokeExpr = invocation.getMatchQueryExpr(); + if (methodInvokeExpr.getParameters().size() == 3) { + SQLExpr extraParamExpr = methodInvokeExpr.getParameters().get(2); + Object[] sqlArgs = invocation.getSqlArgs(); + return ElasticSqlArgTransferHelper.transferSqlArg(extraParamExpr, sqlArgs, false).toString(); } + return StringUtils.EMPTY; + } - int paramCount = methodQueryExpr.getParameters().size(); - if (paramCount != 2 && paramCount != 3) { - throw new ElasticSql2DslException(String.format("[syntax error] There's no %s args method: wildcard", paramCount)); - } + @Override + protected QueryBuilder buildQuery(MethodInvocation invocation, String fieldName, Map extraParams) { + SQLMethodInvokeExpr methodInvokeExpr = invocation.getMatchQueryExpr(); - SQLExpr textExpr = methodQueryExpr.getParameters().get(1); + SQLExpr textExpr = methodInvokeExpr.getParameters().get(1); + Object text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, invocation.getSqlArgs(), false); - String text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, sqlArgs, false).toString(); - if (StringUtils.isEmpty(text)) { - throw new ElasticSql2DslException("[syntax error] Wildcard text can not be blank!"); - } + WildcardQueryBuilder wildcardQuery = QueryBuilders.wildcardQuery(fieldName, text.toString()); + setExtraMatchQueryParam(wildcardQuery, extraParams); + return wildcardQuery; } @Override - @SuppressWarnings("unchecked") - protected AtomQuery parseMethodQueryExpr(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { - SQLExpr queryField = methodQueryExpr.getParameters().get(0); - SQLExpr textExpr = methodQueryExpr.getParameters().get(1); - - Map extraParamMap = null; - if (methodQueryExpr.getParameters().size() == 3) { - SQLExpr ExtraParamExpr = methodQueryExpr.getParameters().get(2); - String extraParam = ElasticSqlArgTransferHelper.transferSqlArg(ExtraParamExpr, sqlArgs, false).toString(); + protected SQLExpr getFieldExpr(MethodInvocation invocation) { + return invocation.getMatchQueryExpr().getParameters().get(0); + } - extraParamMap = buildExtraMethodQueryParamsMap(extraParam); + @Override + protected void checkQueryMethod(MethodInvocation invocation) throws ElasticSql2DslException { + if (Boolean.FALSE == isMatchMethodInvocation(invocation)) { + throw new ElasticSql2DslException( + String.format("[syntax error] Expected wildcard query method name is [wildcard],but get [%s]", + invocation.getMatchQueryExpr().getMethodName())); } - Object text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, sqlArgs, false); + SQLMethodInvokeExpr methodQueryExpr = invocation.getMatchQueryExpr(); - return parseCondition(queryField, new Object[]{text, extraParamMap}, queryAs, new IConditionMethodQueryBuilder() { - @Override - public QueryBuilder buildQuery(String queryFieldName, Object[] parameters) { - WildcardQueryBuilder wildcardQuery = QueryBuilders.wildcardQuery(queryFieldName, parameters[0].toString()); + int paramCount = methodQueryExpr.getParameters().size(); + if (paramCount != 2 && paramCount != 3) { + throw new ElasticSql2DslException(String.format("[syntax error] There's no %s args method: wildcard", paramCount)); + } - if (parameters.length == 2 && parameters[1] != null) { - Map tExtraParamMap = (Map) parameters[1]; - setExtraMatchQueryParam(wildcardQuery, tExtraParamMap); - } + SQLExpr textExpr = methodQueryExpr.getParameters().get(1); - return wildcardQuery; - } - }); + String text = ElasticSqlArgTransferHelper.transferSqlArg(textExpr, invocation.getSqlArgs(), false).toString(); + if (StringUtils.isEmpty(text)) { + throw new ElasticSql2DslException("[syntax error] Wildcard text can not be blank!"); + } } private void setExtraMatchQueryParam(WildcardQueryBuilder wildcardQuery, Map extraParamMap) { diff --git a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/sql/AbstractQueryConditionParser.java b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/sql/AbstractQueryConditionParser.java index 739c3b4..c53f030 100644 --- a/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/sql/AbstractQueryConditionParser.java +++ b/elasticsearch-query-core/src/main/java/org/elasticsearch/dsl/parser/sql/AbstractQueryConditionParser.java @@ -14,9 +14,10 @@ import org.elasticsearch.dsl.parser.query.exact.BetweenAndAtomQueryParser; import org.elasticsearch.dsl.parser.query.exact.BinaryAtomQueryParser; import org.elasticsearch.dsl.parser.query.exact.InListAtomQueryParser; +import org.elasticsearch.dsl.parser.query.method.MethodInvocation; import org.elasticsearch.dsl.parser.query.method.fulltext.FullTextAtomQueryParser; -import org.elasticsearch.dsl.parser.query.method.term.TermLevelAtomQueryParser; import org.elasticsearch.dsl.parser.query.method.script.ScriptAtomQueryParser; +import org.elasticsearch.dsl.parser.query.method.term.TermLevelAtomQueryParser; import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; @@ -25,10 +26,20 @@ public abstract class AbstractQueryConditionParser implements QueryParser { - protected ParseActionListener parseActionListener; + private final TermLevelAtomQueryParser termLevelAtomQueryParser; + private final ScriptAtomQueryParser scriptAtomQueryParser; + private final FullTextAtomQueryParser fullTextAtomQueryParser; + private final BinaryAtomQueryParser binaryQueryParser; + private final InListAtomQueryParser inListQueryParser; + private final BetweenAndAtomQueryParser betweenAndQueryParser; public AbstractQueryConditionParser(ParseActionListener parseActionListener) { - this.parseActionListener = parseActionListener; + termLevelAtomQueryParser = new TermLevelAtomQueryParser(parseActionListener); + scriptAtomQueryParser = new ScriptAtomQueryParser(parseActionListener); + fullTextAtomQueryParser = new FullTextAtomQueryParser(parseActionListener); + binaryQueryParser = new BinaryAtomQueryParser(parseActionListener); + inListQueryParser = new InListAtomQueryParser(parseActionListener); + betweenAndQueryParser = new BetweenAndAtomQueryParser(parseActionListener); } protected BoolQueryBuilder parseQueryConditionExpr(SQLExpr conditionExpr, String queryAs, Object[] sqlArgs) { @@ -80,31 +91,27 @@ private AtomQuery parseAtomQueryCondition(SQLExpr sqlConditionExpr, String query if (sqlConditionExpr instanceof SQLMethodInvokeExpr) { SQLMethodInvokeExpr methodQueryExpr = (SQLMethodInvokeExpr) sqlConditionExpr; - if(ScriptAtomQueryParser.isScriptAtomQuery(methodQueryExpr)) { - ScriptAtomQueryParser scriptAtomQueryParser = new ScriptAtomQueryParser(parseActionListener); - return scriptAtomQueryParser.parseAtomMethodQuery(methodQueryExpr, queryAs, sqlArgs); + MethodInvocation methodInvocation = new MethodInvocation(methodQueryExpr, queryAs, sqlArgs); + + if (scriptAtomQueryParser.isMatchMethodInvocation(methodInvocation)) { + return scriptAtomQueryParser.parseAtomMethodQuery(methodInvocation); } - if (FullTextAtomQueryParser.isFulltextAtomQuery(methodQueryExpr)) { - FullTextAtomQueryParser fullTextAtomQueryParser = new FullTextAtomQueryParser(parseActionListener); + if (fullTextAtomQueryParser.isFulltextAtomQuery(methodQueryExpr)) { return fullTextAtomQueryParser.parseFullTextAtomQuery(methodQueryExpr, queryAs, sqlArgs); } - if (TermLevelAtomQueryParser.isTermLevelAtomQuery(methodQueryExpr)) { - TermLevelAtomQueryParser termLevelAtomQueryParser = new TermLevelAtomQueryParser(parseActionListener); + if (termLevelAtomQueryParser.isTermLevelAtomQuery(methodInvocation)) { return termLevelAtomQueryParser.parseTermLevelAtomQuery(methodQueryExpr, queryAs, sqlArgs); } } else if (sqlConditionExpr instanceof SQLBinaryOpExpr) { - BinaryAtomQueryParser binaryQueryParser = new BinaryAtomQueryParser(parseActionListener); return binaryQueryParser.parseBinaryQuery((SQLBinaryOpExpr) sqlConditionExpr, queryAs, sqlArgs); } else if (sqlConditionExpr instanceof SQLInListExpr) { - InListAtomQueryParser inListQueryParser = new InListAtomQueryParser(parseActionListener); return inListQueryParser.parseInListQuery((SQLInListExpr) sqlConditionExpr, queryAs, sqlArgs); } else if (sqlConditionExpr instanceof SQLBetweenExpr) { - BetweenAndAtomQueryParser betweenAndQueryParser = new BetweenAndAtomQueryParser(parseActionListener); return betweenAndQueryParser.parseBetweenAndQuery((SQLBetweenExpr) sqlConditionExpr, queryAs, sqlArgs); } throw new ElasticSql2DslException(String.format("[syntax error] Can not support query condition type[%s]", sqlConditionExpr.toString())); diff --git a/elasticsearch-query-core/src/test/java/org/elasticsearch/query/SqlParserWhereConditionTest.java b/elasticsearch-query-core/src/test/java/org/elasticsearch/query/SqlParserWhereConditionTest.java index c83b418..bcf034a 100644 --- a/elasticsearch-query-core/src/test/java/org/elasticsearch/query/SqlParserWhereConditionTest.java +++ b/elasticsearch-query-core/src/test/java/org/elasticsearch/query/SqlParserWhereConditionTest.java @@ -15,6 +15,10 @@ import org.junit.Ignore; import org.junit.Test; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; + public class SqlParserWhereConditionTest { @Test @@ -257,4 +261,12 @@ public void testNotExpr() { f2 = parseResult.getWhereCondition(); Assert.assertEquals(f1.toString(), f2.toString()); } + + @Test + public void testMatchQuery() throws Exception { + String sql = "select * from index query term(name, 'abc', 'boost:2.0f') and term(code, '123')"; + ElasticSql2DslParser sql2DslParser = new ElasticSql2DslParser(); + ElasticSqlParseResult parseResult = sql2DslParser.parse(sql); + System.out.println(parseResult.toDsl()); + } } diff --git a/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserLimitTest.xml b/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserLimitTest.xml index 7c1a6e5..45b31ec 100644 --- a/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserLimitTest.xml +++ b/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserLimitTest.xml @@ -1,5 +1,5 @@ - + @@ -61,7 +61,7 @@ - - - + + + \ No newline at end of file diff --git a/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserListenerTest.xml b/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserListenerTest.xml index a39ad81..9f7842a 100644 --- a/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserListenerTest.xml +++ b/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserListenerTest.xml @@ -1,5 +1,5 @@ - + @@ -61,5 +61,5 @@ - + \ No newline at end of file diff --git a/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserOrderByTest.xml b/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserOrderByTest.xml index 06adab4..d024836 100644 --- a/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserOrderByTest.xml +++ b/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserOrderByTest.xml @@ -1,5 +1,5 @@ - + @@ -61,5 +61,5 @@ - + \ No newline at end of file diff --git a/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserQueryTest.xml b/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserQueryTest.xml index e042ded..92769f9 100644 --- a/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserQueryTest.xml +++ b/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserQueryTest.xml @@ -1,5 +1,5 @@ - + @@ -61,14 +61,14 @@ - + - - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserRoutingTest.xml b/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserRoutingTest.xml index 53962f5..e1a5b04 100644 --- a/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserRoutingTest.xml +++ b/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserRoutingTest.xml @@ -1,5 +1,5 @@ - + @@ -62,5 +62,5 @@ - + \ No newline at end of file diff --git a/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserSelectFieldTest.xml b/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserSelectFieldTest.xml index 6d413fe..a61e1d1 100644 --- a/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserSelectFieldTest.xml +++ b/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserSelectFieldTest.xml @@ -1,5 +1,5 @@ - + @@ -61,10 +61,10 @@ - - + + - - + + \ No newline at end of file diff --git a/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserWhereConditionTest.xml b/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserWhereConditionTest.xml index 1599a5a..1d59753 100644 --- a/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserWhereConditionTest.xml +++ b/elasticsearch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserWhereConditionTest.xml @@ -1,5 +1,5 @@ - + @@ -61,13 +61,14 @@ - - - - + + + + - - + + + \ No newline at end of file diff --git a/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserLimitTest.txt b/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserLimitTest.txt index afaaa48..2c2751c 100644 --- a/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserLimitTest.txt +++ b/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserLimitTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: org.elasticsearch.query.SqlParserLimitTest ------------------------------------------------------------------------------- -Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.459 sec +Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.182 sec diff --git a/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserListenerTest.txt b/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserListenerTest.txt index e4686f7..3016b91 100644 --- a/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserListenerTest.txt +++ b/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserListenerTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: org.elasticsearch.query.SqlParserListenerTest ------------------------------------------------------------------------------- -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.01 sec +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.067 sec diff --git a/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserOrderByTest.txt b/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserOrderByTest.txt index 405f51a..76ac5d2 100644 --- a/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserOrderByTest.txt +++ b/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserOrderByTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: org.elasticsearch.query.SqlParserOrderByTest ------------------------------------------------------------------------------- -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.034 sec +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec diff --git a/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserQueryTest.txt b/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserQueryTest.txt index 178ee42..9825a0e 100644 --- a/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserQueryTest.txt +++ b/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserQueryTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: org.elasticsearch.query.SqlParserQueryTest ------------------------------------------------------------------------------- -Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.127 sec +Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047 sec diff --git a/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserRoutingTest.txt b/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserRoutingTest.txt index 2c8dc37..a928058 100644 --- a/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserRoutingTest.txt +++ b/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserRoutingTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: org.elasticsearch.query.SqlParserRoutingTest ------------------------------------------------------------------------------- -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.01 sec +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 sec diff --git a/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserSelectFieldTest.txt b/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserSelectFieldTest.txt index 394f1cd..9e33e13 100644 --- a/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserSelectFieldTest.txt +++ b/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserSelectFieldTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: org.elasticsearch.query.SqlParserSelectFieldTest ------------------------------------------------------------------------------- -Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.028 sec +Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.024 sec diff --git a/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserWhereConditionTest.txt b/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserWhereConditionTest.txt index 83884aa..cead266 100644 --- a/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserWhereConditionTest.txt +++ b/elasticsearch-query-core/target/surefire-reports/org.elasticsearch.query.SqlParserWhereConditionTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: org.elasticsearch.query.SqlParserWhereConditionTest ------------------------------------------------------------------------------- -Tests run: 7, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.059 sec +Tests run: 8, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.056 sec diff --git a/elasticsearch-query-jdbc/target/surefire-reports/TEST-org.elasticsearch.jdbc.ElasticDriverTest.xml b/elasticsearch-query-jdbc/target/surefire-reports/TEST-org.elasticsearch.jdbc.ElasticDriverTest.xml index ce595c5..a428137 100644 --- a/elasticsearch-query-jdbc/target/surefire-reports/TEST-org.elasticsearch.jdbc.ElasticDriverTest.xml +++ b/elasticsearch-query-jdbc/target/surefire-reports/TEST-org.elasticsearch.jdbc.ElasticDriverTest.xml @@ -1,5 +1,5 @@ - + @@ -61,9 +61,9 @@ - - - + + + - + \ No newline at end of file diff --git a/elasticsearch-query-jdbc/target/surefire-reports/TEST-org.elasticsearch.jdbc.GroupByTest.xml b/elasticsearch-query-jdbc/target/surefire-reports/TEST-org.elasticsearch.jdbc.GroupByTest.xml index ea2b579..8933a69 100644 --- a/elasticsearch-query-jdbc/target/surefire-reports/TEST-org.elasticsearch.jdbc.GroupByTest.xml +++ b/elasticsearch-query-jdbc/target/surefire-reports/TEST-org.elasticsearch.jdbc.GroupByTest.xml @@ -1,5 +1,5 @@ - + @@ -61,5 +61,5 @@ - + \ No newline at end of file diff --git a/elasticsearch-query-jdbc/target/surefire-reports/TEST-org.elasticsearch.jdbc.MethodQueryTest.xml b/elasticsearch-query-jdbc/target/surefire-reports/TEST-org.elasticsearch.jdbc.MethodQueryTest.xml index 7ae45f7..7db6e92 100644 --- a/elasticsearch-query-jdbc/target/surefire-reports/TEST-org.elasticsearch.jdbc.MethodQueryTest.xml +++ b/elasticsearch-query-jdbc/target/surefire-reports/TEST-org.elasticsearch.jdbc.MethodQueryTest.xml @@ -1,5 +1,5 @@ - + @@ -61,5 +61,5 @@ - + \ No newline at end of file diff --git a/elasticsearch-query-jdbc/target/surefire-reports/TEST-org.elasticsearch.jdbc.ScriptQueryTest.xml b/elasticsearch-query-jdbc/target/surefire-reports/TEST-org.elasticsearch.jdbc.ScriptQueryTest.xml index ae97f90..4fa7d1b 100644 --- a/elasticsearch-query-jdbc/target/surefire-reports/TEST-org.elasticsearch.jdbc.ScriptQueryTest.xml +++ b/elasticsearch-query-jdbc/target/surefire-reports/TEST-org.elasticsearch.jdbc.ScriptQueryTest.xml @@ -1,5 +1,5 @@ - + @@ -61,5 +61,5 @@ - + \ No newline at end of file diff --git a/elasticsearch-query-jdbc/target/surefire-reports/org.elasticsearch.jdbc.ElasticDriverTest.txt b/elasticsearch-query-jdbc/target/surefire-reports/org.elasticsearch.jdbc.ElasticDriverTest.txt index 076c8be..ba01678 100644 --- a/elasticsearch-query-jdbc/target/surefire-reports/org.elasticsearch.jdbc.ElasticDriverTest.txt +++ b/elasticsearch-query-jdbc/target/surefire-reports/org.elasticsearch.jdbc.ElasticDriverTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: org.elasticsearch.jdbc.ElasticDriverTest ------------------------------------------------------------------------------- -Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.132 sec +Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.602 sec diff --git a/elasticsearch-query-jdbc/target/surefire-reports/org.elasticsearch.jdbc.GroupByTest.txt b/elasticsearch-query-jdbc/target/surefire-reports/org.elasticsearch.jdbc.GroupByTest.txt index d6db77c..c23254d 100644 --- a/elasticsearch-query-jdbc/target/surefire-reports/org.elasticsearch.jdbc.GroupByTest.txt +++ b/elasticsearch-query-jdbc/target/surefire-reports/org.elasticsearch.jdbc.GroupByTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: org.elasticsearch.jdbc.GroupByTest ------------------------------------------------------------------------------- -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.071 sec +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.053 sec diff --git a/elasticsearch-query-jdbc/target/surefire-reports/org.elasticsearch.jdbc.MethodQueryTest.txt b/elasticsearch-query-jdbc/target/surefire-reports/org.elasticsearch.jdbc.MethodQueryTest.txt index cce869d..6fb35c1 100644 --- a/elasticsearch-query-jdbc/target/surefire-reports/org.elasticsearch.jdbc.MethodQueryTest.txt +++ b/elasticsearch-query-jdbc/target/surefire-reports/org.elasticsearch.jdbc.MethodQueryTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: org.elasticsearch.jdbc.MethodQueryTest ------------------------------------------------------------------------------- -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.087 sec +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.033 sec diff --git a/elasticsearch-query-jdbc/target/surefire-reports/org.elasticsearch.jdbc.ScriptQueryTest.txt b/elasticsearch-query-jdbc/target/surefire-reports/org.elasticsearch.jdbc.ScriptQueryTest.txt index f807303..fb1e561 100644 --- a/elasticsearch-query-jdbc/target/surefire-reports/org.elasticsearch.jdbc.ScriptQueryTest.txt +++ b/elasticsearch-query-jdbc/target/surefire-reports/org.elasticsearch.jdbc.ScriptQueryTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: org.elasticsearch.jdbc.ScriptQueryTest ------------------------------------------------------------------------------- -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.039 sec +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.031 sec