将Elasticsearch传输客户端升级到Rest客户端?

时间:2018-04-06 06:30:08

标签: java elasticsearch rest-client

有人可以帮我找到相应的API参考资料,以便将这些API更新为Rest而不是transportClient吗?

String[] indices = transportClient.admin()
        .indices()
        .prepareGetIndex()
        .addIndices("_" + tid + "-")
        .execute()
        .actionGet()
        .getIndices();

transportClient.admin()
        .indices()
        .prepareFlush(indexName)
        .get();

transportClient.admin()
        .indices()
        .prepareRefresh(indexName)
        .get();

transportClient.admin()
        .cluster()
        .state(clusterStateRequest)
        .actionGet()
        .getState()
        .getMetaData()
        .index(indexName)
        .getAliases();

1 个答案:

答案 0 :(得分:0)

如果你想使用RestHighLevelClient,你只需要改变你的  TransportClient RestClient就像这样

RestHighLevelClient client = new RestHighLevelClient(
        RestClient.builder(
                new HttpHost("localhost", 9200, "http"),
                new HttpHost("localhost", 9201, "http")));

https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.2/java-rest-low-usage-initialization.html

编辑:关于FLUSH / REFRESH和CLUSTER_STATE,此功能将在下一个版本中提供......

(在6.3.0上)刷新 - > https://github.com/elastic/elasticsearch/pull/27799(在6.3.0上)Flush - > https://github.com/elastic/elasticsearch/pull/28852群集状态 - >没开始

相关问题