简体   繁体   中英

ElasticSearch: Java API from 2.x to 5.x issues

I'm changing from ES 2.x java API to 5.x.

In 2.x I was used to do that in order to create an alias:

AliasAction action = new AliasAction(AliasAction.Type.ADD)
            .alias(username)
            .index(ElasticsearchRepository.ELASTICSEARCH_INDEX)
            .searchRouting(username)
            .indexRouting(username)
            .filter(QueryBuilders.termQuery("user", username));

    request = request.addAliasAction(action);

I0ve tried to figure out how to move that on 5.x. Nevertheless, I don't quite understand how to get that.

Any ideas?

From what I see here : https://www.javadoc.io/doc/org.elasticsearch/elasticsearch/5.0.0

It seems like they changed the way to attribute the alias to something like this :

    IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest();
    indicesAliasesRequest.addAliasAction(IndicesAliasesRequest.AliasActions.add()
                                       .alias("TheAliasToAdd")
                                       .index("TheIndexToAddTheAliasTo"));
    client.admin().indices().aliases(indicesAliasesRequest);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM