我正在尝试从一个非常旧的elasticsearch版本迁移到最新的6.3.0版本。我找到了这个链接ElasticSearch TransportClient version 5.6,它显示了我试图实现的一个模式,但我无法让它工作:
import org.elasticsearch.common.settings.Settings
import org.elasticsearch.client.transport.TransportClient
import org.elasticsearch.transport.client.PreBuiltTransportClient
trait ElasticSearchClient {
lazy val client: TransportClient = new PreBuiltTransportClient(
Settings.builder()
.put("cluster.name", clusterName)
// etc...
.build())
我得到了错误:
[error] object client is not a member of package org.elasticsearch.transport
[error] import org.elasticsearch.transport.client.PreBuiltTransportClient
[error] ^
我已经尝试了备用import org.elasticsearch.client.transport.PreBuiltTransportClient
,但仍然不能解决。
如果我尝试使用lazy val client: TransportClient = new TransportClient(
,它会显示class TransportClient is abstract; cannot be instantiated
。
如果我尝试使用lazy val client: TransportClient = TransportClient.builder().
,它会显示value builder is not a member of object org.elasticsearch.client.transport.TransportClient
。
我找不到关于这方面的任何其他文档或帖子,我想知道创建TransportClient
对象的正确模式是什么?
https://stackoverflow.com/questions/51866749
复制相似问题