I'm posting my temporal solution as this can take a while to get fixed.
Taking the suggestion that @dadoonet gave me, I'm using the same RestClient instance needed to create the ElasticsearchClient to perform the Rest request.
Step1: Create the RestClient as specified in the documentation.
Step2: Create the Request and set in its body the pipeline settings.
public boolean createUpdatePipeline(){
Request request = new Request("PUT", "/_ingest/pipeline/my_test_pipeline");
String elserPipeline =
"{\n" +
" \"processors\": [\n" +
" {\n" +
" \"inference\": {\n" +
" \"model_id\": \".elser_model_1\",\n" +
" \"target_field\": \"ml\",\n" +
" \"field_map\": { \n" +
" \"text\": \"text_field\"\n" +
" },\n" +
" \"inference_config\": {\n" +
" \"text_expansion\": { \n" +
" \"results_field\": \"tokens\"\n" +
" }\n" +
" }\n" +
" }\n" +
" }\n" +
" ]\n" +
"}";
request.setJsonEntity(elserPipeline);
Response response = elasticRestClient.performRequest(request); // elasticRestClient is from step1.
if(response.getStatusLine().getStatusCode() == 200){
ObjectMapper objectMapper = new ObjectMapper();
String acknowledged = EntityUtils.toString(response.getEntity());
AcknowledgedResponse ak_response = objectMapper.readValue(acknowledged, CreatePipelineResponse.class);
return ak_response.acknowledged(); // create the CreatePipelineResponse class implementing the AcknowledgedResponse interface from Elastic, that way when the error is fixed it won't require many code changes.
} else return false;
}
I posted this solution in case someone else runs into the same problem as I did.
Do I need to create a new bug so this error can be seen by the Elasticsearch/java team?