0

I am upgrading some legacy code to utilize OpenSearch Java Api Client v1.0.0. I am limited on version because of jdk 11 required.

I would like to do something similar:

POST xx/_update/123
{
  "doc": {
    "dateLastModified":1682281110874,
    "FR":"sss",
    "someOtherId":12,
    "EN":"sss"
  }
}

Here is the code I believed should of worked but I believe I am not allowed to use String

    public void updateAsync(@NotNull PK id, @NotNull String document) throws IOException {
        
        openSearchAsyncClient.update(new UpdateRequest.Builder<T, String>()
                                         .index(index)
                                         .id(convertId(id))
                                         .doc(document)
                                         .build(), targetType);
}

I cannot seem to pass to it any other types of document than the Data Class. To make it work with old code, I need to be able to provide it a string.

I cannot find any documentations on Update.

I get a OpenSearchException with this detailed message:

Request failed: [x_content_parse_exception] [1:8] [UpdateRequest] doc doesn’t support values of type: VALUE_STRING
Reza M.
  • 1,205
  • 14
  • 33
  • It looks like your `document` variable is a string while [it should](https://github.com/opensearch-project/opensearch-java/blob/main/java-client/src/main/java/org/opensearch/client/opensearch/core/UpdateRequest.java#L507) be a `TPartialDocument` instead – Val Apr 24 '23 at 14:08
  • It's generic type ? – Reza M. Apr 24 '23 at 16:50
  • Does this help? https://stackoverflow.com/a/72026251/4604579 – Val Apr 24 '23 at 16:55
  • No, unfortunately, all of them required an Object class. The best I can do is a Map .... I will have to probably go and change a lot of code to comply – Reza M. Apr 24 '23 at 17:58

0 Answers0