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:
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.2.0</version>
</dependency>
And I've tried to the indexing like this:
Script script = new Script(
"ctx._source.municipio="+municipio
+"; 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");
}
}