-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Add opensearch-java
client support
#19
Comments
https://opensearch.org/docs/latest/clients/java-rest-high-level/
|
hi @reta it's been a while, hope you're doing well. Was wondering your thoughts on this issue. Now that high level rest client is deprecated, do you think it makes more sense to just update this code to use I might have some cycles to look at this. |
Hey @johnament , great to hear from you!
I think it makes sense to go with |
@johnament it seems like the urgency for this one has elevated a bit, AFAIK Spring Data Elasticsearch in 5.2 drops the RHCL based support completely, have you started some work already? If not, I could kick it off and would appreciate your help, thank you. |
We are removing the Elasticsearch RestHighLevelClient, but your code is derived from the abstract class that is the base for the old and new client, so this removal should not affect you. |
is there a plan for when this will happen? it'd be great to get rid of the RHLC dependency when working with |
There is intent to do that, no timelines though, sadly |
@reta apologies. no work has started on my side as we are able to do what we need using |
No problem, thanks a lot for the update @johnament , I hope to pick it up shortly (at least have a draft pull request to collaborate), thank you! |
Also, I'm sure you already realize it but when cutting over I found it easier to start with something like this, which constructs the java client from the underlying rest client via transport, this way the configuration code can be cutover separately from the consuming code: diff --git a/settings.gradle.kts b/settings.gradle.kts
index 2180e9b..c1df11d 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -31,6 +31,7 @@ dependencyResolutionManagement {
create("opensearchLibs") {
version("opensearch", "2.11.0")
+ library("java", "org.opensearch.client:opensearch-java:2.8.1")
library("client", "org.opensearch.client", "opensearch-rest-client").versionRef("opensearch")
library("high-level-client", "org.opensearch.client", "opensearch-rest-high-level-client").versionRef("opensearch")
library("sniffer", "org.opensearch.client", "opensearch-rest-client-sniffer").versionRef("opensearch")
diff --git a/spring-data-opensearch/build.gradle.kts b/spring-data-opensearch/build.gradle.kts
index a981afe..24217e0 100644
--- a/spring-data-opensearch/build.gradle.kts
+++ b/spring-data-opensearch/build.gradle.kts
@@ -26,6 +26,7 @@ dependencies {
api(opensearchLibs.high.level.client) {
exclude("commons-logging", "commons-logging")
}
+ api(opensearchLibs.java)
implementation(jacksonLibs.core)
implementation(jacksonLibs.databind)
diff --git a/spring-data-opensearch/src/main/java/org/opensearch/data/client/orhlc/RestClients.java b/spring-data-opensearch/src/main/java/org/opensearch/data/client/orhlc/RestClients.java
index 5a84f7a..95c0003 100644
--- a/spring-data-opensearch/src/main/java/org/opensearch/data/client/orhlc/RestClients.java
+++ b/spring-data-opensearch/src/main/java/org/opensearch/data/client/orhlc/RestClients.java
@@ -30,6 +30,10 @@ import org.apache.http.protocol.HttpContext;
import org.opensearch.client.RestClient;
import org.opensearch.client.RestClientBuilder;
import org.opensearch.client.RestHighLevelClient;
+import org.opensearch.client.json.jackson.JacksonJsonpMapper;
+import org.opensearch.client.opensearch.OpenSearchClient;
+import org.opensearch.client.transport.OpenSearchTransport;
+import org.opensearch.client.transport.rest_client.RestClientTransport;
import org.springframework.data.elasticsearch.support.HttpHeaders;
import org.springframework.util.Assert;
@@ -139,6 +143,11 @@ public final class RestClients {
return rest().getLowLevelClient();
}
+ default OpenSearchClient javaClient() {
+ final OpenSearchTransport transport = new RestClientTransport(lowLevelRest(), new JacksonJsonpMapper());
+ return new OpenSearchClient(transport);
+ }
+
@Override
default void close() throws IOException {
rest().close(); |
Thanks @johnament , to be fair I have not considered this option (primarily because it keeps dependency on |
So yeah, I had incorrectly assumed that the Now that there's starting to be bigger forking behaviors here, is that still the right approach to think of? For many of the older models they just maintained arbitrary maps. The new java client now uses more concrete classes. |
Correct, the idea was to follow the similar approach Spring Data Elasticsearch took with 2 independent clients for Elasticsearch: RestClient and |
So how would you see handling something like this? In Opensearch, Basically my fundamental question is should Spring Data Opensearch continue to be derived from Spring Data Elasticsearch or should it be its own independent module (so that incorrect classes don't leak). |
This is very good question, the abstractions provided by Spring Data Elasticsearch allowed us to cut a lot of corners, but the key to that was the fact that ES and OS APIs didn't diverge too much (if at all). I think the vision for a long term is that Spring Data Opensearch will become independent. |
Hello. @reta But it seems that only RestHighLevelClient is still supported in |
Hey @AntCode97
👍
That is correct at the moment, the work is ongoing [1], there are some changes on
Using 2 clients is indeed a bit annoying however if you use [1] #227 |
Is your feature request related to a problem?
The only supported client at the moment is RHLC, we should also add opensearch-java support.
What solution would you like?
Support opensearch-java
What alternatives have you considered?
Keep only RHLC
Do you have any additional context?
N/A
The text was updated successfully, but these errors were encountered: