Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- name: Install Elasticsearch
env:
ES_VERSION: 9.1.4
ES_VERSION: 9.1.9
run: |
sudo rm -rf /var/lib/elasticsearch
curl -fsSL --retry 3 --retry-delay 5 "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}-amd64.deb" -o elasticsearch.deb
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jdk:

before_install:
- sudo rm -rf /var/lib/elasticsearch
- curl https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-9.1.4-amd64.deb -o elasticsearch.deb && sudo dpkg -i --force-confnew elasticsearch.deb
- curl https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-9.1.9-amd64.deb -o elasticsearch.deb && sudo dpkg -i --force-confnew elasticsearch.deb
- sudo cp ./src/test/resources/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml
- sudo cat /etc/elasticsearch/elasticsearch.yml
- sudo java -version
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.nlpcn</groupId>
<artifactId>elasticsearch-sql</artifactId>
<version>9.1.4.0</version>
<version>9.1.9.0</version>
<packaging>jar</packaging>
<description>Query elasticsearch using SQL</description>
<name>elasticsearch-sql</name>
Expand Down Expand Up @@ -44,7 +44,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<runSuite>**/MainTestSuite.class</runSuite>
<elasticsearch.plugin.name>sql</elasticsearch.plugin.name>
<elasticsearch.version>9.1.4</elasticsearch.version>
<elasticsearch.version>9.1.9</elasticsearch.version>
<elasticsearch.plugin.classname>org.elasticsearch.plugin.nlpcn.SqlPlug</elasticsearch.plugin.classname>
<druid.version>1.2.15</druid.version>
<guava.version>32.0.0-jre</guava.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import jakarta.json.JsonValue;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.Version;
import org.elasticsearch.action.admin.cluster.state.ClusterStateAction;
import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest;
Expand Down Expand Up @@ -88,6 +89,7 @@ public class ClusterStateActionHandler extends ActionHandler<ClusterStateRequest
private static final String KEY_MAPPINGS = "mappings";
private static final String KEY_MAPPINGS_HASH = "mappings_hash";
private static final String KEY_MAPPINGS_UPDATED_VERSION = "mappings_updated_version";
private static final String KEY_TRANSPORT_VERSION = "transport_version";
private static final String KEY_ALIASES = "aliases";
private static final String KEY_ROLLOVER_INFOS = "rollover_info";
private static final String KEY_WARMERS = "warmers";
Expand Down Expand Up @@ -392,6 +394,9 @@ private IndexMetadata loadIndexMetadataFromXContent(XContentParser parser) throw
case KEY_MAPPINGS_UPDATED_VERSION:
builder.mappingsUpdatedVersion(IndexVersion.fromId(parser.intValue()));
break;
case KEY_TRANSPORT_VERSION:
builder.transportVersion(TransportVersion.fromId(parser.intValue()));
break;
case KEY_MAPPINGS_HASH:
logger.warn("Skipping mappings hash");
parser.skipChildren();
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/org/nlpcn/es4sql/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,12 @@ public static Object getScriptValueWithQuote(SQLExpr expr, String quote) throws
return ((SQLNullExpr) expr).toString().toLowerCase();
} else if (expr instanceof SQLBinaryOpExpr) {
//zhongshu-comment 该分支由忠树添加
String left = "doc['" + ((SQLBinaryOpExpr) expr).getLeft().toString() + "'].value";
String operator = ((SQLBinaryOpExpr) expr).getOperator().getName();
String right = "doc['" + ((SQLBinaryOpExpr) expr).getRight().toString() + "'].value";
SQLBinaryOpExpr sqlExpr = (SQLBinaryOpExpr) expr;
Object leftValue = getScriptValueWithQuote(sqlExpr.getLeft(), quote);
String left = sqlExpr.getLeft() instanceof SQLBinaryOpExpr ? "(" + leftValue + ")" : leftValue.toString();
String operator = sqlExpr.getOperator().getName();
Object rightValue = getScriptValueWithQuote(sqlExpr.getRight(), quote);
String right = sqlExpr.getRight() instanceof SQLBinaryOpExpr ? "(" + rightValue + ")" : rightValue.toString();
return left + operator + right;
}
throw new SqlParseException("could not parse sqlBinaryOpExpr need to be identifier/valuable got " + expr.getClass().toString() + " with value:" + expr.toString());
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/nlpcn/es4sql/query/maker/AggMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ private AggregationBuilder termsAgg(MethodField field) throws SqlParseException
IncludeExclude include = null, exclude = null;
for (KVValue kv : field.getParams()) {
if(kv.value.toString().contains("doc[")) {
String script = kv.value + "; return " + kv.key;
String script = kv.value.toString();
terms.script(new Script(script));
} else {
value = kv.value.toString();
Expand Down Expand Up @@ -665,7 +665,7 @@ private DateHistogramAggregationBuilder dateHistogram(MethodField field) throws
String value = null;
for (KVValue kv : field.getParams()) {
if(kv.value.toString().contains("doc[")) {
String script = kv.value + "; return " + kv.key;
String script = kv.value.toString();
dateHistogram.script(new Script(script));
} else {
value = kv.value.toString();
Expand Down Expand Up @@ -750,7 +750,7 @@ private HistogramAggregationBuilder histogram(MethodField field) throws SqlParse
String value = null;
for (KVValue kv : field.getParams()) {
if(kv.value.toString().contains("doc[")) {
String script = kv.value + "; return " + kv.key;
String script = kv.value.toString();
histogram.script(new Script(script));
} else {
value = kv.value.toString();
Expand Down