Skip to content

Commit f4f8dcc

Browse files
committed
Merge commit 'f231da8e8b5092cf5f839e6f1c67c4404425e9db' into elastic2.0
Conflicts: pom.xml
2 parents f5977b3 + f231da8 commit f4f8dcc

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ Elasticsearch-SQL
22
=================
33
**1.X** [![1.X Build Status](https://travis-ci.org/NLPchina/elasticsearch-sql.svg?branch=master)](https://travis-ci.org/NLPchina/elasticsearch-sql) <br>
44
**2.0.0** [![2.0.0 Build Status](https://travis-ci.org/NLPchina/elasticsearch-sql.svg?branch=elastic2.0)](https://travis-ci.org/NLPchina/elasticsearch-sql)<br>
5-
**2.1.0** [![2.1.0 Build Status](https://travis-ci.org/NLPchina/elasticsearch-sql.svg?branch=elastic2.0)](https://travis-ci.org/NLPchina/elasticsearch-sql)<br>
5+
**2.1.0** [![2.1.0 Build Status](https://travis-ci.org/NLPchina/elasticsearch-sql.svg?branch=elastic2.1)](https://travis-ci.org/NLPchina/elasticsearch-sql)<br>
6+
**2.1.1** [![2.1.1 Build Status](https://travis-ci.org/NLPchina/elasticsearch-sql.svg?branch=elastic2.1.1)](https://travis-ci.org/NLPchina/elasticsearch-sql)<br>
67

78
Query elasticsearch using familiar SQL syntax.
89
You can also use ES functions in SQL.
@@ -21,23 +22,28 @@ Install as plugin:
2122
Versions
2223
------------
2324

24-
| elasticsearch version | latest version | remarks | branch |
25-
| --------------------- | ------------- | ----------------------------- | ---------- |
26-
| 1.X | 1.4.7 | tested against elastic 1.4-1.6 | master |
27-
| 2.0.0 | 2.0.2 | delete commands not supported | elastic2.0 |
28-
| 2.1.0 | 2.1.0 | delete commands not supported | elastic2.1 |
25+
| elasticsearch version | latest version | remarks | branch |
26+
| --------------------- | ------------- | ----------------------------- | ------------ |
27+
| 1.X | 1.4.8 | tested against elastic 1.4-1.6 | master |
28+
| 2.0.0 | 2.0.3 | delete commands not supported | elastic2.0 |
29+
| 2.1.0 | 2.1.0.1 | delete commands not supported | elastic2.1 |
30+
| 2.1.1 | 2.1.1 | delete commands not supported | elastic2.1.1 |
2931

3032
### Elasticsearch 1.X
3133
````
32-
./bin/plugin -u https://github.com/NLPchina/elasticsearch-sql/releases/download/1.4.7/elasticsearch-sql-1.4.7.zip --install sql
34+
./bin/plugin -u https://github.com/NLPchina/elasticsearch-sql/releases/download/1.4.8/elasticsearch-sql-1.4.8.zip --install sql
3335
````
3436
### Elasticsearch 2.0.0
3537
````
36-
./bin/plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/2.0.2/elasticsearch-sql-2.0.2.zip
38+
./bin/plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/2.0.3/elasticsearch-sql-2.0.3.zip
3739
````
3840
### Elasticsearch 2.1.0
3941
````
40-
./bin/plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/2.1.0/elasticsearch-sql-2.1.0.zip
42+
./bin/plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/2.1.0.1/elasticsearch-sql-2.1.0.1.zip
43+
````
44+
### Elasticsearch 2.1.1
45+
````
46+
./bin/plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/2.1.1/elasticsearch-sql-2.1.1.zip
4147
````
4248
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}`.
4349

src/main/java/org/nlpcn/es4sql/parse/SqlParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ private Where findWhere(SQLExpr where) throws SqlParseException {
8383
private boolean isCond(SQLBinaryOpExpr expr) {
8484
SQLExpr leftSide = expr.getLeft();
8585
if(leftSide instanceof SQLMethodInvokeExpr){
86-
return isAllowedMethodOnConditionLeft((SQLMethodInvokeExpr) leftSide);
86+
return isAllowedMethodOnConditionLeft((SQLMethodInvokeExpr) leftSide,expr.getOperator());
8787
}
8888
return leftSide instanceof SQLIdentifierExpr || leftSide instanceof SQLPropertyExpr || leftSide instanceof SQLVariantRefExpr;
8989
}
9090

91-
private boolean isAllowedMethodOnConditionLeft(SQLMethodInvokeExpr method) {
92-
return method.getMethodName().toLowerCase().equals("nested");
91+
private boolean isAllowedMethodOnConditionLeft(SQLMethodInvokeExpr method, SQLBinaryOperator operator) {
92+
return method.getMethodName().toLowerCase().equals("nested") && !operator.isLogical();
9393
}
9494

9595
public void parseWhere(SQLExpr expr, Where where) throws SqlParseException {

src/test/java/org/nlpcn/es4sql/SqlParserTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,17 @@ public void fieldsAsNumbersOnWhere() throws SqlParseException {
768768
Assert.assertEquals("3", condition.getName());
769769
}
770770

771+
772+
@Test
773+
public void complexNestedAndOtherQuery() throws SqlParseException {
774+
String query = "select * from x where nested('path',path.x=3) and y=3";
775+
Select select = parser.parseSelect((SQLQueryExpr) queryToExpr(query));
776+
LinkedList<Where> wheres = select.getWhere().getWheres();
777+
Assert.assertEquals(2, wheres.size());
778+
Assert.assertEquals("AND path NESTED_COMPLEX AND ( AND path.x EQ 3 ) ",wheres.get(0).toString());
779+
Assert.assertEquals("AND y EQ 3",wheres.get(1).toString());
780+
}
781+
771782
private SQLExpr queryToExpr(String query) {
772783
return new ElasticSqlExprParser(query).expr();
773784
}

0 commit comments

Comments
 (0)