Skip to content

forcemerge with wait_for_completion=false lead to response error: MissingRequiredPropertyException: Missing required property 'ForcemergeResponse.shards' #468

Open

Description

@akisaya

Java API client version

8.5.2

Java version

1.8

Elasticsearch Version

8.5.0

Problem description

ForcemergeResponse forcemergeResp = client.indices().forcemerge(r ->
                            r.index(curIndex).maxNumSegments(maxSegment).waitForCompletion(false));

when use the code above to force merge segments without waiting, the response will fail because of mandatory response property check, and we got such error response

co.elastic.clients.util.MissingRequiredPropertyException: Missing required property 'ForcemergeResponse.shards'
	at co.elastic.clients.util.ApiTypeHelper.requireNonNull(ApiTypeHelper.java:76)
	at co.elastic.clients.elasticsearch._types.ShardsOperationResponseBase.<init>(ShardsOperationResponseBase.java:57)
	at co.elastic.clients.elasticsearch.indices.forcemerge.ForceMergeResponseBody.<init>(ForceMergeResponseBody.java:55)
	at co.elastic.clients.elasticsearch.indices.ForcemergeResponse.<init>(ForcemergeResponse.java:48)
	at co.elastic.clients.elasticsearch.indices.ForcemergeResponse.<init>(ForcemergeResponse.java:44)
	at co.elastic.clients.elasticsearch.indices.ForcemergeResponse$Builder.build(ForcemergeResponse.java:79)
	at co.elastic.clients.elasticsearch.indices.ForcemergeResponse$Builder.build(ForcemergeResponse.java:62)
	at co.elastic.clients.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:80)
	at co.elastic.clients.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:43)
	at co.elastic.clients.transport.rest_client.RestClientTransport.decodeResponse(RestClientTransport.java:325)
	at co.elastic.clients.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:295)
	at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:148)
	at co.elastic.clients.elasticsearch.indices.ElasticsearchIndicesClient.forcemerge(ElasticsearchIndicesClient.java:836)
	at co.elastic.clients.elasticsearch.indices.ElasticsearchIndicesClient.forcemerge(ElasticsearchIndicesClient.java:852)

the request url looks like <index>/_forcemerge?wait_for_completion=false&max_num_segments=1
and the repsonse will be like

{
  "completed": false,
  "task": {
    "node": "PM0rlfWdQiiTjjmVzHgs-A",
    "id": 2726788,
    "type": "transport",
    "action": "indices:admin/forcemerge",
    "description": "Force-merge indices [dw_mobdb_dim_tripshoot_embedding_for_search-20221221151817], maxSegments[1], onlyExpungeDeletes[false], flush[true]",
    "start_time_in_millis": 1671612028318,
    "running_time_in_nanos": 147222061523,
    "cancellable": false,
    "headers": {}
  }
}

there is no _shards property if task is not completed.

Activity

  1. akisaya commented on Dec 21, 2022

    @akisaya
    Author

    using

    ApiTypeHelper.DisabledChecksHandle disabledChecksHandle =
                        ApiTypeHelper.DANGEROUS_disableRequiredPropertiesCheck(true);
    

    can be a work around

  2. akisaya commented on Dec 22, 2022

    @akisaya
    Author

    found a disscussion elastic/elasticsearch-specification#1767 is opening, hope it works well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

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