How to create an update request with multiple fields with Java HIGH API

Hello, I'm trying to update some fields of a document based on a query, but I am having problems to push its changes in the UpdateRequest, I am probably doing the script in a wrong way.

I am using that client:


And I've tried to the indexing like this:

Script script = new Script(
    +"; ctx._source.codMunicipio="+codMunicipio
    +"; ctx._source.mesorregiao="+mesorregiao
    +"; ctx._source.microrregiao="+microrregiao
    +"; ctx._source.uf="+uf

 // Faz a chamada para padronizar
UpdateRequest request = new UpdateRequest(index, doc_id).script(script);

 try {
        client.update(request, RequestOptions.DEFAULT);
  } catch (ElasticsearchException e) {
          if (e.status() == RestStatus.NOT_FOUND) {
                System.out.println("File not found");

Which are?

It just don't work, i'll try something else, if it doesn't work, i'll ask for help here again

What makes you think it did not work? Could you share more details about the full test you are running?

it doesn't show any errors, but the fields aren't updated, probably because that script is wrong, i'll try using a jsonString as it shows in the documentation:

String jsonString = "{" +
        "\"updated\":\"2017-01-01\"," +
        "\"reason\":\"daily update\"" +

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.