Skip to content

Missing required property 'IndexResponse.primaryTerm' #472

Closed

Description

Java API client version

8.5.1

Java version

17

Elasticsearch Version

8.5.3

Problem description

When using the index api with a pipeline that returns noop, the _primary_term property is not present in the response, which leads to this exception:

Missing required property 'IndexResponse.primaryTerm'
co.elastic.clients.util.MissingRequiredPropertyException: Missing required property 'IndexResponse.primaryTerm'

The workaround provided at MissingRequiredPropertyException does not work as it throws another exception:

Cannot invoke "java.lang.Long.longValue()" because the return value of "co.elastic.clients.util.ApiTypeHelper.requireNonNull(Object, Object, String)" is null
java.lang.NullPointerException: Cannot invoke "java.lang.Long.longValue()" because the return value of "co.elastic.clients.util.ApiTypeHelper.requireNonNull(Object, Object, String)" is null

Using dev tools to test the pipeline, we can see that the _primary_term property is not present in the response

// PIPELINE RETURNING NOOP
PUT _ingest/pipeline/noop-pipeline
{
  "processors": [
    {
      "drop": {
        "if": "true"
      }
    }
  ]
}

PUT test-index/_doc/test?pipeline=noop-pipeline
{
  "test": "test"
}

// PIPELINE RETURNING CREATED
PUT _ingest/pipeline/created-pipeline
{
  "processors": [
    {
      "drop": {
        "if": "false"
      }
    }
  ]
}

PUT test-index/_doc/test?pipeline=created-pipeline
{
  "test": "test"
}

Responses:

# PUT _ingest/pipeline/noop-pipeline 200 OK
{
  "acknowledged": true
}
# PUT test-index/_doc/test?pipeline=noop-pipeline 200 OK
{
  "_index": "test-index",
  "_id": "test",
  "_version": -3,
  "result": "noop",
  "_shards": {
    "total": 0,
    "successful": 0,
    "failed": 0
  }
}
# PUT _ingest/pipeline/created-pipeline 200 OK
{
  "acknowledged": true
}
# PUT test-index/_doc/test?pipeline=created-pipeline 201 Created
{
  "_index": "test-index",
  "_id": "test",
  "_version": 1,
  "result": "created",
  "_shards": {
    "total": 2,
    "successful": 1,
    "failed": 0
  },
  "_seq_no": 0,
  "_primary_term": 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions