Skip to content

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

@jbaudisc

Description

@jbaudisc

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.opensearch.client.RestHighLevelClient.index() method there is a mapping function named RequestConverters::index which does not set require_alias parameter.

Issue was also present in Elasticsearch, see elastic/elasticsearch#67819 and fixed with Elasticsearch 7.13.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions