Skip to content

Text_expansion from InferenceConfig is not supported upon creating a Pipeline #667

Closed
@adrianpbv

Description

@adrianpbv

Java API client version

8.9.1

Java version

8

Elasticsearch Version

8.9.1

Problem description

I'm trying to create a pipeline that ingest data with the ELSER model. In the class PutPipelineRequest, InferenceConfig doesn’t support “text_expansion” value from the json file, 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)

It seems that InferenceConfig only supports regression and classification types. As the ELSER model was recently introduced this is missed from the JavaApiClient v8.9.1, that is supposed to be updated with features released in Elastic v8.9.1.

The code to create the pipeline programmatically in java is:

InputStream input = new ClassPathResource("elser_pipeline_config.json").getInputStream();

PutPipelineRequest request = PutPipelineRequest.of(pl->pl
                    .id("my_pipeline_test")
                    .withJson(input)
            );
elasticsearchClient.ingest().putPipeline(request);

// elser_pipeline_config.json :
{
  "description":"My test elser pipeline",
  "processors": [
    {
      "inference": {
        "model_id": ".elser_model_1",
        "target_field": "ml",
        "field_map": { 
          "text": "text_field"
        },
        "inference_config": {
          "text_expansion": { 
            "results_field": "tokens"
          }
        }
      }
    }
  ]
}

As a temporal solution I created this workaround if someone runs into the same error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: SpecificationRelated to the API spec used to generate client code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions