Skip to content

High level REST client index() is not respecting the indexRequest.setRequireAlias(true) method call #67819

@jaanek

Description

@jaanek

The following code:

IndexRequest indexRequest = new IndexRequest("test-index").id("1");
indexRequest.source(objectMapper.writeValueAsBytes(doc), XContentType.JSON);
indexRequest.setRequireAlias(true);
client.index(indexRequest, DEFAULT);

Expected behaviour:
Should throw a RuntimeException (because of indexRequest.setRequireAlias(true)) and in our tests ("test-index") does not exist.

How it worked:
However, it did not throw an Exception but instead created a new index named "test-index" (default behaviour).

It seems it does not take indexRequest.setRequireAlias(true); call into account. Checking the code in org.elasticsearch.client.RestHighLevelClient.index() method there is a mapping function named RequestConverters::index which does not set require_alias parameter as described in docs: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html

Elasticsearch version (server / java api) 7.10.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions