Skip to content

Commit

Permalink
es 8.16.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
shi-yuan committed Feb 4, 2025
1 parent 95e8b0a commit 465da6a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jdk:

before_install:
- sudo rm -rf /var/lib/elasticsearch
- curl https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.15.5-amd64.deb -o elasticsearch.deb && sudo dpkg -i --force-confnew elasticsearch.deb
- curl https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.16.0-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>8.15.5.0</version>
<version>8.16.0.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>8.15.5</elasticsearch.version>
<elasticsearch.version>8.16.0</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
3 changes: 2 additions & 1 deletion src/main/java/org/nlpcn/es4sql/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.telemetry.metric.MeterRegistry;
import org.elasticsearch.threadpool.DefaultBuiltInExecutorBuilders;
import org.elasticsearch.threadpool.ThreadPool;

import java.util.HashMap;
Expand All @@ -22,7 +23,7 @@ public static String sqlToEsQuery(String sql) throws Exception {
// .put(ThreadContext.PREFIX + ".key2", "val 2")
// .build();

ThreadPool threadPool = new ThreadPool(settings, MeterRegistry.NOOP);
ThreadPool threadPool = new ThreadPool(settings, MeterRegistry.NOOP, new DefaultBuiltInExecutorBuilders());
Client client = new NodeClient(settings, threadPool);
SearchDao searchDao = new org.nlpcn.es4sql.SearchDao(client);
try {
Expand Down
7 changes: 4 additions & 3 deletions src/test/java/org/nlpcn/es4sql/MainTestSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.reindex.DeleteByQueryRequestBuilder;
import org.elasticsearch.plugin.nlpcn.client.ElasticsearchRestClient;
Expand Down Expand Up @@ -82,7 +83,7 @@ public static void setUp() throws Exception {
String clusterName = nodeInfos.getClusterName().value();
System.out.println(String.format("Found cluster... cluster name: %s", clusterName));

client.admin().cluster().prepareUpdateSettings().setTransientSettings(ImmutableMap.of(DestructiveOperations.REQUIRES_NAME_SETTING.getKey(), false)).get();
client.admin().cluster().prepareUpdateSettings(TimeValue.ONE_MINUTE, TimeValue.ONE_MINUTE).setTransientSettings(ImmutableMap.of(DestructiveOperations.REQUIRES_NAME_SETTING.getKey(), false)).get();

// Load test data.
loadBulk("src/test/resources/online.json", TEST_INDEX_ONLINE);
Expand Down Expand Up @@ -147,7 +148,7 @@ private static void createTestIndex(String index) {
}

private static void deleteTestIndex(String index) {
if(client.admin().cluster().prepareState().execute().actionGet().getState().getMetadata().hasIndex(index)){
if(client.admin().cluster().prepareState(TimeValue.ONE_MINUTE).execute().actionGet().getState().getMetadata().hasIndex(index)){
client.admin().indices().prepareDelete(index).get();
}
}
Expand Down Expand Up @@ -446,7 +447,7 @@ private static TransportAddress getTransportAddress() throws UnknownHostExceptio
}

private static ElasticsearchTransport getElasticsearchTransport(RestClient restClient) {
RestClientOptions.Builder transportOptionsBuilder = new RestClientOptions(RequestOptions.DEFAULT).toBuilder();
RestClientOptions.Builder transportOptionsBuilder = new RestClientOptions(RequestOptions.DEFAULT, true).toBuilder();

ContentType jsonContentType = Version.VERSION == null ? ContentType.APPLICATION_JSON
: ContentType.create("application/vnd.elasticsearch+json",
Expand Down

0 comments on commit 465da6a

Please sign in to comment.