diff --git a/README.md b/README.md
index aefdf328..9908b6f6 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ Install as plugin:
### Elasticsearch 1.6.X
````
-./bin/plugin -u https://github.com/NLPchina/elasticsearch-sql/releases/download/1.4.1/elasticsearch-sql-1.4.1.zip --install sql
+./bin/plugin -u https://github.com/NLPchina/elasticsearch-sql/releases/download/1.4.2/elasticsearch-sql-1.4.2.zip --install sql
````
After doing this, you need to restart the Elasticsearch server. Otherwise you may get errors like `Invalid index name [sql], must not start with '']; ","status":400}`.
diff --git a/pom.xml b/pom.xml
index bd2929c1..22998f05 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
org.nlpcn
elasticsearch-sql
- 1.4.1
+ 1.4.2
jar
Query elasticsearch using SQL
elasticsearch-sql
diff --git a/src/main/java/org/nlpcn/es4sql/parse/ElasticLexer.java b/src/main/java/org/nlpcn/es4sql/parse/ElasticLexer.java
index 24f0a75e..c281d7b2 100644
--- a/src/main/java/org/nlpcn/es4sql/parse/ElasticLexer.java
+++ b/src/main/java/org/nlpcn/es4sql/parse/ElasticLexer.java
@@ -88,6 +88,6 @@ public void scanIdentifier() {
private boolean isElasticIdentifierChar(char ch) {
- return ch == '*' || ch == ':' || ch == '-' || isIdentifierChar(ch);
+ return ch == '*' || ch == ':' || ch == '-' || ch == '.' || isIdentifierChar(ch);
}
}
diff --git a/src/main/java/org/nlpcn/es4sql/parse/SqlParser.java b/src/main/java/org/nlpcn/es4sql/parse/SqlParser.java
index 0cc752e4..e85367cb 100644
--- a/src/main/java/org/nlpcn/es4sql/parse/SqlParser.java
+++ b/src/main/java/org/nlpcn/es4sql/parse/SqlParser.java
@@ -437,7 +437,7 @@ private List getConnectedFields(List conditions, String alias)
fields.add(new Field(condition.getName().replaceFirst(prefix,""),null));
}
else {
- if(! ((condition.getValue() instanceof SQLPropertyExpr)||(condition.getValue() instanceof String))){
+ if(! ((condition.getValue() instanceof SQLPropertyExpr)||(condition.getValue() instanceof SQLIdentifierExpr)||(condition.getValue() instanceof String))){
throw new SqlParseException("conditions on join should be one side is firstTable second Other , condition was:" + condition.toString());
}
String aliasDotValue = condition.getValue().toString();
@@ -517,7 +517,7 @@ private void removeAliasPrefix(Where where, String alias) {
private void addIfConditionRecursive(Where where, List conditions) throws SqlParseException {
if(where instanceof Condition){
Condition cond = (Condition) where;
- if( ! ((cond.getValue() instanceof SQLPropertyExpr)|| (cond.getValue() instanceof String))){
+ if( ! ((cond.getValue() instanceof SQLIdentifierExpr) ||(cond.getValue() instanceof SQLPropertyExpr)|| (cond.getValue() instanceof String))){
throw new SqlParseException("conditions on join should be one side is secondTable OPEAR firstTable, condition was:" + cond.toString());
}
conditions.add(cond);
diff --git a/src/main/java/org/nlpcn/es4sql/query/ESActionFactory.java b/src/main/java/org/nlpcn/es4sql/query/ESActionFactory.java
index 93ee7a89..442d4b70 100644
--- a/src/main/java/org/nlpcn/es4sql/query/ESActionFactory.java
+++ b/src/main/java/org/nlpcn/es4sql/query/ESActionFactory.java
@@ -45,7 +45,8 @@ public class ESActionFactory {
* @return Query object.
*/
public static QueryAction create(Client client, String sql) throws SqlParseException, SQLFeatureNotSupportedException {
- String firstWord = sql.substring(0, sql.indexOf(' '));
+ sql = sql.replaceAll("\n"," ");
+ String firstWord = sql.substring(0, sql.indexOf(' '));
switch (firstWord.toUpperCase()) {
case "SELECT":
SQLQueryExpr sqlExpr = (SQLQueryExpr) toSqlExpr(sql);
diff --git a/src/test/java/org/nlpcn/es4sql/SqlParserTests.java b/src/test/java/org/nlpcn/es4sql/SqlParserTests.java
index 2620b4d6..b4f67904 100644
--- a/src/test/java/org/nlpcn/es4sql/SqlParserTests.java
+++ b/src/test/java/org/nlpcn/es4sql/SqlParserTests.java
@@ -394,7 +394,14 @@ public void innerQueryTestTwoQueries() throws SqlParseException {
Assert.assertEquals(2,select.getSubQueries().size());
}
-
+ @Test
+ public void indexWithDotsAndHyphen() throws SqlParseException {
+ String query = "select * from data-2015.08.22";
+ SQLExpr sqlExpr = queryToExpr(query);
+ Select select = parser.parseSelect((SQLQueryExpr) sqlExpr);
+ Assert.assertEquals(1,select.getFrom().size());
+ Assert.assertEquals("data-2015.08.22",select.getFrom().get(0).getIndex());
+ }
private SQLExpr queryToExpr(String query) {
return new ElasticSqlExprParser(query).expr();
@@ -410,8 +417,7 @@ private boolean conditionExist(List conditions, String from, String t
boolean fromIsEqual = condition.getName().equals(from);
if(!fromIsEqual) continue;
- SQLPropertyExpr value = (SQLPropertyExpr) condition.getValue();
- String[] valueAliasAndField = value.toString().split("\\.",2);
+ String[] valueAliasAndField = condition.getValue().toString().split("\\.",2);
boolean toFieldNameIsEqual = valueAliasAndField[1].equals(toField);
boolean toAliasIsEqual = valueAliasAndField[0].equals(toAlias);
boolean toIsEqual = toAliasIsEqual && toFieldNameIsEqual;