Skip to content

Commit 256bf23

Browse files
committed
es 6.3.0 support
1 parent 1fff861 commit 256bf23

File tree

10 files changed

+43
-28
lines changed

10 files changed

+43
-28
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ before_install:
1717
# update to java 8
1818
- sudo update-java-alternatives -s java-8-oracle
1919
- export JAVA_HOME=/usr/lib/jvm/java-8-oracle
20-
- wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.deb && sudo dpkg -i --force-confnew elasticsearch-6.2.4.deb
20+
- wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.0.deb && sudo dpkg -i --force-confnew elasticsearch-6.3.0.deb
2121
- sudo cp ./src/test/resources/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml
2222
- sudo cat /etc/elasticsearch/elasticsearch.yml
2323
- sudo java -version

pom.xml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.nlpcn</groupId>
55
<artifactId>elasticsearch-sql</artifactId>
6-
<version>6.2.4.6</version>
6+
<version>6.3.0.0</version>
77
<packaging>jar</packaging>
88
<description>Query elasticsearch using SQL</description>
99
<name>elasticsearch-sql</name>
@@ -45,7 +45,7 @@
4545
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4646
<runSuite>**/MainTestSuite.class</runSuite>
4747
<elasticsearch.plugin.name>sql</elasticsearch.plugin.name>
48-
<elasticsearch.version>6.2.4</elasticsearch.version>
48+
<elasticsearch.version>6.3.0</elasticsearch.version>
4949
<elasticsearch.plugin.classname>org.elasticsearch.plugin.nlpcn.SqlPlug</elasticsearch.plugin.classname>
5050
</properties>
5151

@@ -93,14 +93,15 @@
9393
<dependency>
9494
<groupId>org.locationtech.spatial4j</groupId>
9595
<artifactId>spatial4j</artifactId>
96-
<version>0.6</version>
96+
<version>0.7</version>
9797
</dependency>
9898

99-
<dependency>
100-
<groupId>com.vividsolutions</groupId>
101-
<artifactId>jts</artifactId>
102-
<version>1.13</version>
103-
</dependency>
99+
<dependency>
100+
<groupId>org.locationtech.jts</groupId>
101+
<artifactId>jts-core</artifactId>
102+
<version>1.15.0</version>
103+
<scope>provided</scope>
104+
</dependency>
104105

105106
<dependency>
106107
<groupId>org.elasticsearch</groupId>
@@ -116,6 +117,20 @@
116117
<scope>provided</scope>
117118
</dependency>
118119

120+
<dependency>
121+
<groupId>com.unboundid</groupId>
122+
<artifactId>unboundid-ldapsdk</artifactId>
123+
<version>3.2.0</version>
124+
<scope>provided</scope>
125+
</dependency>
126+
127+
<dependency>
128+
<groupId>org.bouncycastle</groupId>
129+
<artifactId>bcprov-jdk15on</artifactId>
130+
<version>1.58</version>
131+
<scope>provided</scope>
132+
</dependency>
133+
119134
<dependency>
120135
<groupId>log4j</groupId>
121136
<artifactId>log4j</artifactId>

src/main/java/org/elasticsearch/plugin/nlpcn/ElasticUtils.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import com.google.common.collect.ImmutableMap;
44
import org.elasticsearch.action.search.SearchRequestBuilder;
55
import org.elasticsearch.action.search.SearchResponse;
6-
import org.elasticsearch.action.search.SearchType;
76
import org.elasticsearch.client.Client;
7+
import org.elasticsearch.common.bytes.BytesReference;
88
import org.elasticsearch.common.unit.TimeValue;
99
import org.elasticsearch.common.xcontent.XContentBuilder;
1010
import org.elasticsearch.common.xcontent.XContentFactory;
@@ -67,7 +67,6 @@ public static String hitsAsStringResult(SearchHits results, MetaSearchResult met
6767
, "failed", metaResults.getFailedShards()));
6868
builder.field("hits",hits) ;
6969
builder.endObject();
70-
71-
return builder.string();
70+
return BytesReference.bytes(builder).utf8ToString();
7271
}
7372
}

src/main/java/org/nlpcn/es4sql/domain/hints/HintFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
55
import com.fasterxml.jackson.dataformat.yaml.YAMLParser;
6+
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
67
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
78
import org.elasticsearch.common.xcontent.yaml.YamlXContentParser;
89
import org.nlpcn.es4sql.exception.SqlParseException;
@@ -100,7 +101,7 @@ public static Hint getHintFromString(String hintAsString) throws SqlParseExcepti
100101
YAMLParser yamlParser = null;
101102
try {
102103
yamlParser = yamlFactory.createParser(heighlightParam.toCharArray());
103-
YamlXContentParser yamlXContentParser = new YamlXContentParser(NamedXContentRegistry.EMPTY, yamlParser);
104+
YamlXContentParser yamlXContentParser = new YamlXContentParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, yamlParser);
104105
Map<String, Object> map = yamlXContentParser.map();
105106
hintParams.add(map);
106107
} catch (IOException e) {

src/main/java/org/nlpcn/es4sql/query/QueryAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.elasticsearch.action.search.SearchRequestBuilder;
55
import org.elasticsearch.action.support.IndicesOptions;
66
import org.elasticsearch.client.Client;
7+
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
78
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
89
import org.elasticsearch.common.xcontent.json.JsonXContentParser;
910
import org.elasticsearch.index.query.QueryBuilders;
@@ -37,7 +38,7 @@ protected void updateRequestWithCollapse(Select select, SearchRequestBuilder req
3738
JsonFactory jsonFactory = new JsonFactory();
3839
for (Hint hint : select.getHints()) {
3940
if (hint.getType() == HintType.COLLAPSE && hint.getParams() != null && 0 < hint.getParams().length) {
40-
try (JsonXContentParser parser = new JsonXContentParser(NamedXContentRegistry.EMPTY, jsonFactory.createParser(hint.getParams()[0].toString()))) {
41+
try (JsonXContentParser parser = new JsonXContentParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, jsonFactory.createParser(hint.getParams()[0].toString()))) {
4142
request.setCollapse(CollapseBuilder.fromXContent(parser));
4243
} catch (IOException e) {
4344
throw new SqlParseException("could not parse collapse hint: " + e.getMessage());

src/main/java/org/nlpcn/es4sql/query/join/JoinRequestBuilder.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@
55
import org.elasticsearch.action.ActionRequestBuilder;
66
import org.elasticsearch.action.ActionResponse;
77
import org.elasticsearch.action.search.MultiSearchRequest;
8+
import org.elasticsearch.common.bytes.BytesReference;
89
import org.elasticsearch.common.xcontent.ToXContent;
910
import org.elasticsearch.common.xcontent.XContentBuilder;
1011
import org.elasticsearch.common.xcontent.XContentFactory;
1112
import org.elasticsearch.common.xcontent.XContentType;
12-
import org.nlpcn.es4sql.domain.Field;
1313
import org.nlpcn.es4sql.query.SqlElasticRequestBuilder;
1414

1515
import java.io.IOException;
16-
import java.util.List;
17-
import java.util.Map;
1816

1917
/**
2018
* Created by Eliran on 15/9/2015.
@@ -55,7 +53,7 @@ public String explain() {
5553

5654
XContentBuilder secondBuilder = XContentFactory.contentBuilder(XContentType.JSON).prettyPrint();
5755
secondTable.getRequestBuilder().request().source().toXContent(secondBuilder, ToXContent.EMPTY_PARAMS);
58-
String explained = String.format(" first query:\n%s\n second query:\n%s", firstBuilder.string(), secondBuilder.string());
56+
String explained = String.format(" first query:\n%s\n second query:\n%s", BytesReference.bytes(firstBuilder).utf8ToString(), BytesReference.bytes(secondBuilder).utf8ToString());
5957

6058
return explained;
6159
} catch (IOException e) {

src/main/java/org/nlpcn/es4sql/query/maker/AggMaker.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.*;
77
import java.util.stream.Collectors;
88

9+
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
910
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
1011
import org.elasticsearch.common.xcontent.XContentParser;
1112
import org.elasticsearch.common.xcontent.json.JsonXContent;
@@ -296,15 +297,15 @@ private AggregationBuilder termsAgg(MethodField field) throws SqlParseException
296297
terms.executionHint(value);
297298
break;
298299
case "include":
299-
try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, value)) {
300+
try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, value)) {
300301
parser.nextToken();
301302
include = IncludeExclude.parseInclude(parser);
302303
} catch (IOException e) {
303304
throw new SqlParseException("parse include[" + value + "] error: " + e.getMessage());
304305
}
305306
break;
306307
case "exclude":
307-
try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, value)) {
308+
try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, value)) {
308309
parser.nextToken();
309310
exclude = IncludeExclude.parseExclude(parser);
310311
} catch (IOException e) {

src/main/java/org/nlpcn/es4sql/query/maker/Maker.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import org.apache.lucene.search.join.ScoreMode;
1414
import org.elasticsearch.common.geo.GeoPoint;
1515
import org.elasticsearch.common.geo.builders.ShapeBuilder;
16+
import org.elasticsearch.common.geo.parsers.ShapeParser;
17+
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
1618
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
1719
import org.elasticsearch.common.xcontent.ToXContent;
1820
import org.elasticsearch.common.xcontent.XContentParser;
@@ -326,9 +328,9 @@ private String fixJsonFromElastic(String elasticJson) {
326328

327329
private ShapeBuilder getShapeBuilderFromJson(String json) throws IOException {
328330
XContentParser parser = null;
329-
parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, json);
331+
parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, json);
330332
parser.nextToken();
331-
return ShapeBuilder.parse(parser);
333+
return ShapeParser.parse(parser);
332334
}
333335

334336
private String trimApostrophes(String str) {

src/main/java/org/nlpcn/es4sql/query/multi/MultiQueryRequestBuilder.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44
import org.elasticsearch.action.ActionRequest;
55
import org.elasticsearch.action.ActionRequestBuilder;
66
import org.elasticsearch.action.ActionResponse;
7-
import org.elasticsearch.action.search.MultiSearchRequest;
87
import org.elasticsearch.action.search.SearchRequestBuilder;
8+
import org.elasticsearch.common.bytes.BytesReference;
99
import org.elasticsearch.common.xcontent.ToXContent;
1010
import org.elasticsearch.common.xcontent.XContentBuilder;
1111
import org.elasticsearch.common.xcontent.XContentFactory;
1212
import org.elasticsearch.common.xcontent.XContentType;
1313
import org.nlpcn.es4sql.domain.Field;
1414
import org.nlpcn.es4sql.domain.Select;
15-
import org.nlpcn.es4sql.exception.SqlParseException;
16-
import org.nlpcn.es4sql.query.DefaultQueryAction;
1715
import org.nlpcn.es4sql.query.SqlElasticRequestBuilder;
1816

1917
import java.io.IOException;
@@ -56,7 +54,7 @@ public String explain() {
5654

5755
XContentBuilder secondBuilder = XContentFactory.contentBuilder(XContentType.JSON).prettyPrint();
5856
this.secondSearchRequest.request().source().toXContent(secondBuilder, ToXContent.EMPTY_PARAMS);
59-
String explained = String.format("performing %s on :\n left query:\n%s\n right query:\n%s", this.relation.name,firstBuilder.string(), secondBuilder.string());
57+
String explained = String.format("performing %s on :\n left query:\n%s\n right query:\n%s", this.relation.name, BytesReference.bytes(firstBuilder).utf8ToString(), BytesReference.bytes(secondBuilder).utf8ToString());
6058

6159
return explained;
6260
} catch (IOException e) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import org.elasticsearch.index.query.QueryBuilders;
1717
import org.elasticsearch.index.reindex.DeleteByQueryAction;
1818
import org.elasticsearch.index.reindex.DeleteByQueryRequestBuilder;
19-
import org.elasticsearch.transport.client.PreBuiltTransportClient;
19+
import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient;
2020
import org.junit.AfterClass;
2121
import org.junit.BeforeClass;
2222
import org.junit.runner.RunWith;
@@ -50,7 +50,7 @@ public class MainTestSuite {
5050
@BeforeClass
5151
public static void setUp() throws Exception {
5252
Settings settings = Settings.builder().put("client.transport.ignore_cluster_name",true).build();
53-
client = new PreBuiltTransportClient(settings).addTransportAddress(getTransportAddress());
53+
client = new PreBuiltXPackTransportClient(settings).addTransportAddress(getTransportAddress());
5454

5555
NodesInfoResponse nodeInfos = client.admin().cluster().prepareNodesInfo().get();
5656
String clusterName = nodeInfos.getClusterName().value();

0 commit comments

Comments
 (0)