Skip to content
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

[BUG] Opensearch 2.x failing with Elasticsearch 7.10.2 Rest High Level Client #12262

Closed
devkg4ai opened this issue Feb 8, 2024 · 2 comments
Closed
Labels
bug Something isn't working Clients Clients within the Core repository such as High level Rest client and low level client untriaged

Comments

@devkg4ai
Copy link

devkg4ai commented Feb 8, 2024

Describe the bug

Hi All,

We are in a weird situation where we are facing issue while updating the document using the Elasticsearch Rest High Level Client 7.10.2 into Opensearch 2.4.0.

We are facing below error
Caused by: java.io.IOException: Unable to parse response body for Response{requestLine=POST /test/_update/51?timeout=1m HTTP/1.1, host=https://<host>:9200, response=HTTP/1.1 200 OK} at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1533) at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1484) at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1454) at org.elasticsearch.client.RestHighLevelClient.update(RestHighLevelClient.java:921) at org.example.ElasticsearchTest.updateDoc(ElasticsearchTest.java:111) ... 1 more Caused by: java.lang.NullPointerException at java.base/java.util.Objects.requireNonNull(Objects.java:221) at org.elasticsearch.action.DocWriteResponse.<init>(DocWriteResponse.java:127) at org.elasticsearch.action.update.UpdateResponse.<init>(UpdateResponse.java:58) at org.elasticsearch.action.update.UpdateResponse$Builder.build(UpdateResponse.java:155) at org.elasticsearch.action.update.UpdateResponse.fromXContent(UpdateResponse.java:119) at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1793) at org.elasticsearch.client.RestHighLevelClient.lambda$performRequestAndParseEntity$8(RestHighLevelClient.java:1455) at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1531) ... 5 more

Related component

Clients

To Reproduce

  1. final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();

     credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("", ""));
    
     RestClientBuilder builder = RestClient.builder(new HttpHost("<host>", 9200, "https"))
             .setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider));
     ;
     RestHighLevelClient client;
     client = new RestHighLevelClient(builder);
    

updateDoc(client,INDEX_NAME,DOCUMENT_ID); //pass the values

public static void updateDoc(RestHighLevelClient client, String index, String id){
try {
// Create the request
UpdateRequest request = new UpdateRequest(index, id);

        // Prepare the updated fields as a Map
        Map<String, Object> fieldsToUpdate = new HashMap<>();
        fieldsToUpdate.put("<filed_name>", "random_value");
        // ... add more fields as needed
        // Set the updated fields in the request

        request.doc(fieldsToUpdate);
        UpdateResponse updateResponse = client.update(request, RequestOptions.DEFAULT);

        // Handle the response
        if (updateResponse.getResult() == DocWriteResponse.Result.UPDATED) {
            System.out.println("Document updated successfully!");
        } else {
            // Handle other possible outcomes (created, not_found, etc.)
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

Expected behavior

Document should be updated as per below documentation
https://opensearch.org/docs/2.11/clients/#legacy-clients

Additional Details

Plugins
opensearch-alerting
opensearch-anomaly-detection
opensearch-asynchronous-search
opensearch-cross-cluster-replication
opensearch-geospatial
opensearch-index-management
opensearch-job-scheduler
opensearch-knn
opensearch-ml
opensearch-neural-search
opensearch-notifications
opensearch-notifications-core
opensearch-observability
opensearch-performance-analyzer
opensearch-reports-scheduler
opensearch-security
opensearch-security-analytics
opensearch-sql

Host/Environment (please complete the following information):

  • OS: Ubuntu
  • Version 22
@devkg4ai devkg4ai added bug Something isn't working untriaged labels Feb 8, 2024
@github-actions github-actions bot added the Clients Clients within the Core repository such as High level Rest client and low level client label Feb 8, 2024
@devkg4ai devkg4ai changed the title [BUG] Opensearch 2.x failing with Elasticsearch OSS 7.10.2 Rest High Level Client [BUG] Opensearch 2.x failing with Elasticsearch 7.10.2 Rest High Level Client Feb 8, 2024
@dblock
Copy link
Member

dblock commented Feb 9, 2024

Do you mean this is a documentation bug and it should say that clients should work with OpenSearch 1.x (not 2.x)? If so I will move it to https://github.com/opensearch-project/documentation-website/, but also please do feel free to just fix it there!

@peternied
Copy link
Member

[Triage - attendees 1 2 3 4 5 6 7 8]
@devkg4ai Thanks for filing. Thanks for creating this issue; however, it isn't being accepted due to OpenSearch 2.X not being wire compatible with ES 7.10.

It would be useful to update the documentation website if this isn't captured, or at least file an issue there as @dblock suggests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Clients Clients within the Core repository such as High level Rest client and low level client untriaged
Projects
None yet
Development

No branches or pull requests

3 participants