Skip to content

Commit 467df7b

Browse files
authored
chore(deps): bump elasticsearch-java from 8.12.0 to 9.3.0 (#713)
## AgentScope-Java Version 1.0.9 ## Description * chore(deps): bump elasticsearch-java from 8.12.0 to 9.3.0 * Closes: #710 ## Checklist Please check the following items before code is ready to be reviewed. - [x] Code has been formatted with `mvn spotless:apply` - [x] All tests are passing (`mvn test`) - [x] Javadoc comments are complete and follow project conventions - [x] Related documentation has been updated (e.g. links, examples, etc.) - [x] Code is ready for review
1 parent c470c83 commit 467df7b

5 files changed

Lines changed: 44 additions & 26 deletions

File tree

agentscope-dependencies-bom/pom.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@
8383
<slf4j.version>2.0.17</slf4j.version>
8484
<qdrant.version>1.16.2</qdrant.version>
8585
<milvus.version>2.6.13</milvus.version>
86-
<elasticsearch.version>8.12.0</elasticsearch.version>
86+
<httpclient5.version>5.6</httpclient5.version>
87+
<elasticsearch.version>9.3.0</elasticsearch.version>
8788
<postgresql.version>42.7.9</postgresql.version>
8889
<pgvector.version>0.1.6</pgvector.version>
8990
<pdfbox.version>3.0.6</pdfbox.version>
@@ -111,7 +112,6 @@
111112
<kotlin.coroutines.version>1.10.2</kotlin.coroutines.version>
112113
<jgit.version>7.5.0.202512021534-r</jgit.version>
113114

114-
115115
<spotless.version>3.2.1</spotless.version>
116116
<maven-gpg-plugin.version>3.2.8</maven-gpg-plugin.version>
117117
<maven-deploy-plugin.version>3.1.4</maven-deploy-plugin.version>
@@ -240,6 +240,13 @@
240240
<version>${qdrant.version}</version>
241241
</dependency>
242242

243+
<!-- Apache HTTP Client 5 -->
244+
<dependency>
245+
<groupId>org.apache.httpcomponents.client5</groupId>
246+
<artifactId>httpclient5</artifactId>
247+
<version>${httpclient5.version}</version>
248+
</dependency>
249+
243250
<!-- Elasticsearch Java SDK -->
244251
<dependency>
245252
<groupId>co.elastic.clients</groupId>

agentscope-examples/advanced/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<dependency>
4545
<groupId>co.elastic.clients</groupId>
4646
<artifactId>elasticsearch-java</artifactId>
47-
<version>8.12.0</version>
47+
<version>9.3.0</version>
4848
</dependency>
4949

5050
<!-- Spring Boot BOM -->

agentscope-extensions/agentscope-extensions-rag-simple/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@
7676
<artifactId>milvus-sdk-java</artifactId>
7777
</dependency>
7878

79+
<!-- Apache HTTP Client 5 -->
80+
<dependency>
81+
<groupId>org.apache.httpcomponents.client5</groupId>
82+
<artifactId>httpclient5</artifactId>
83+
</dependency>
84+
7985
<!-- Elasticsearch Java SDK -->
8086
<dependency>
8187
<groupId>co.elastic.clients</groupId>

agentscope-extensions/agentscope-extensions-rag-simple/src/main/java/io/agentscope/core/rag/store/ElasticsearchStore.java

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import co.elastic.clients.elasticsearch.ElasticsearchClient;
1919
import co.elastic.clients.elasticsearch._types.mapping.DenseVectorProperty;
20+
import co.elastic.clients.elasticsearch._types.mapping.DenseVectorSimilarity;
2021
import co.elastic.clients.elasticsearch._types.mapping.KeywordProperty;
2122
import co.elastic.clients.elasticsearch._types.mapping.Property;
2223
import co.elastic.clients.elasticsearch._types.mapping.TextProperty;
@@ -31,7 +32,8 @@
3132
import co.elastic.clients.elasticsearch.indices.ExistsRequest;
3233
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
3334
import co.elastic.clients.transport.ElasticsearchTransport;
34-
import co.elastic.clients.transport.rest_client.RestClientTransport;
35+
import co.elastic.clients.transport.rest5_client.Rest5ClientTransport;
36+
import co.elastic.clients.transport.rest5_client.low_level.Rest5Client;
3537
import com.fasterxml.jackson.databind.ObjectMapper;
3638
import io.agentscope.core.message.ContentBlock;
3739
import io.agentscope.core.message.TextBlock;
@@ -44,13 +46,13 @@
4446
import java.util.List;
4547
import java.util.Map;
4648
import javax.net.ssl.SSLContext;
47-
import org.apache.http.HttpHost;
48-
import org.apache.http.auth.AuthScope;
49-
import org.apache.http.auth.UsernamePasswordCredentials;
50-
import org.apache.http.conn.ssl.NoopHostnameVerifier;
51-
import org.apache.http.impl.client.BasicCredentialsProvider;
52-
import org.apache.http.ssl.SSLContextBuilder;
53-
import org.elasticsearch.client.RestClient;
49+
import org.apache.hc.client5.http.auth.AuthScope;
50+
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
51+
import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
52+
import org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy;
53+
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
54+
import org.apache.hc.core5.http.HttpHost;
55+
import org.apache.hc.core5.ssl.SSLContextBuilder;
5456
import org.slf4j.Logger;
5557
import org.slf4j.LoggerFactory;
5658
import reactor.core.publisher.Mono;
@@ -94,7 +96,7 @@ public class ElasticsearchStore implements VDBStoreBase, AutoCloseable {
9496

9597
private final String indexName;
9698
private final int dimensions;
97-
private final RestClient restClient;
99+
private final Rest5Client restClient;
98100
private final ElasticsearchTransport transport;
99101
private final ElasticsearchClient client;
100102
private final boolean disableSslVerification;
@@ -110,8 +112,9 @@ private ElasticsearchStore(Builder builder) throws VectorStoreException {
110112
BasicCredentialsProvider credsProv = new BasicCredentialsProvider();
111113
if (builder.username != null && builder.password != null) {
112114
credsProv.setCredentials(
113-
AuthScope.ANY,
114-
new UsernamePasswordCredentials(builder.username, builder.password));
115+
new AuthScope(null, -1),
116+
new UsernamePasswordCredentials(
117+
builder.username, builder.password.toCharArray()));
115118
}
116119

117120
final SSLContext sslContext;
@@ -127,29 +130,30 @@ private ElasticsearchStore(Builder builder) throws VectorStoreException {
127130
HttpHost host = HttpHost.create(builder.url);
128131

129132
this.restClient =
130-
RestClient.builder(host)
133+
Rest5Client.builder(host)
131134
.setHttpClientConfigCallback(
132135
httpClientBuilder -> {
133136
if (builder.username != null) {
134137
httpClientBuilder.setDefaultCredentialsProvider(
135138
credsProv);
136139
}
137-
140+
})
141+
.setConnectionManagerCallback(
142+
connectionManager -> {
138143
if (builder.url != null
139-
&& builder.url.startsWith("https")) {
140-
httpClientBuilder.setSSLContext(sslContext);
141-
if (builder.disableSslVerification) {
142-
httpClientBuilder.setSSLHostnameVerifier(
143-
NoopHostnameVerifier.INSTANCE);
144-
}
144+
&& builder.url.startsWith("https")
145+
&& builder.disableSslVerification) {
146+
connectionManager.setTlsStrategy(
147+
new DefaultClientTlsStrategy(
148+
sslContext,
149+
NoopHostnameVerifier.INSTANCE));
145150
}
146-
return httpClientBuilder;
147151
})
148152
.build();
149153

150154
// 2. Create Transport and Client
151155
this.transport =
152-
new RestClientTransport(restClient, new JacksonJsonpMapper(OBJECT_MAPPER));
156+
new Rest5ClientTransport(restClient, new JacksonJsonpMapper(OBJECT_MAPPER));
153157
this.client = new ElasticsearchClient(transport);
154158

155159
// 3. Ensure Index Exists
@@ -348,7 +352,7 @@ private void ensureIndex() throws VectorStoreException {
348352
new DenseVectorProperty.Builder()
349353
.dims(dimensions)
350354
.index(true)
351-
.similarity("cosine")
355+
.similarity(DenseVectorSimilarity.Cosine)
352356
.build())
353357
.build();
354358

agentscope-extensions/agentscope-extensions-rag-simple/src/test/java/io/agentscope/core/rag/store/ElasticsearchStoreTest.java

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

2929
import co.elastic.clients.elasticsearch.ElasticsearchClient;
3030
import co.elastic.clients.elasticsearch._types.Result;
31+
import co.elastic.clients.elasticsearch._types.mapping.DenseVectorSimilarity;
3132
import co.elastic.clients.elasticsearch._types.mapping.Property;
3233
import co.elastic.clients.elasticsearch.core.BulkRequest;
3334
import co.elastic.clients.elasticsearch.core.BulkResponse;
@@ -277,7 +278,7 @@ void testEnsureIndexCreatesIndex() throws VectorStoreException, IOException {
277278
Property vectorProp = props.get("vector");
278279
assertTrue(vectorProp.isDenseVector());
279280
assertEquals(TEST_DIMENSIONS, vectorProp.denseVector().dims());
280-
assertEquals("cosine", vectorProp.denseVector().similarity());
281+
assertEquals(DenseVectorSimilarity.Cosine, vectorProp.denseVector().similarity());
281282
assertTrue(vectorProp.denseVector().index());
282283

283284
// Verify Content field

0 commit comments

Comments
 (0)