Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jaanek opened this issue Jan 21, 2021 · 2 comments
Labels
>bug Team:Clients Meta label for clients team

Comments

@jaanek
Copy link

jaanek commented Jan 21, 2021

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

@jaanek jaanek added >bug needs:triage Requires assignment of a team area label labels Jan 21, 2021
@elasticmachine elasticmachine added the Team:Data Management Meta label for data/management team label Jan 21, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (Team:Core/Features)

@mayya-sharipova mayya-sharipova removed Team:Data Management Meta label for data/management team needs:triage Requires assignment of a team area label labels Jan 21, 2021
@jtibshirani jtibshirani added the Team:Clients Meta label for clients team label Jan 26, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/clients-team (Team:Clients)

martijnvg pushed a commit to martijnvg/elasticsearch that referenced this issue Apr 20, 2021
…astic#67865)

The main changes are:
* Set the require_alias parameter in the reindex, index and update methods in RequestConverters class.
* Test that the parameter can be parsed correctly.

Closes elastic#67819.
martijnvg added a commit that referenced this issue Apr 20, 2021
…1914)

Backporting #67865 to 7.x branch.

The main changes are:
* Set the require_alias parameter in the reindex, index and update methods in RequestConverters class.
* Test that the parameter can be parsed correctly.

Closes #67819.

Co-authored-by: bellengao <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug Team:Clients Meta label for clients team
Projects
None yet
Development

No branches or pull requests

4 participants