When creating a PutPipelineRequest with the Java client version 8.9.1, InferenceConfig doesn’t support “text_expansion” value, an error is thrown co.elastic.clients.json.JsonpMappingException: Error deserializing co.elastic.clients.elasticsearch.ingest.InferenceConfig: Unknown field 'text_expansion' (JSON path: processors[0].inference.inference_config.text_expansion)
If the pipeline is created with Elastic Api following the steps from the documentation there is no error . Maybe this is a bug in the java client, and it hasn't been updated yet.
Here is the code I used to create the pipeline programmatically in java:
What can I do to create the pipeline from Java?
If I create it with the Low Level Client I'll have to have two active clients (Low and High level clients), that would not be optimal.
Thank you.
I hope @swallez have a way to address the error. It's better to make it work with the high level java client to avoid deserialization work and object creation.
InferenceConfig currently only supports classification and regression types.
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?
I created the issue with the workaround solution. It should be noted that making a text_expansion query is not supported by the Java API Client yet, version 8.10.1.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.