简体   繁体   English

ElasticSearch:Java API从2.x到5.x的问题

[英]ElasticSearch: Java API from 2.x to 5.x issues

I'm changing from ES 2.x java API to 5.x. 我从ES 2.x Java API更改为5.x。

In 2.x I was used to do that in order to create an alias: 在2.x中,我用来创建别名:

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. 我试图弄清楚如何在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 从我在这里看到的: 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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