我需要使用Nest执行跨集群搜索,但我无法找到一种方法。
Uri elasticNode =新Uri(elasticSearchUri);ConnectionSettings nodeSettings = new nodeSettings ElasticClient elasticClient = new ElasticClient(nodeSettings);
也找不到关于它的文档。
任何帮助都将不胜感激。
发布于 2021-05-12 11:00:27
对于跨簇搜索,首先需要配置至少一个远程集群。
var pool = new SingleNodeConnectionPool(new Uri("http://example.com:9200"));
var settings = new ConnectionSettings(pool);
var client = new ElasticClient(settings);
var putSettingsResponse = client.Cluster.PutSettings(s => s
.Persistent(d => d
.Add("cluster.remote.cluster_two.seeds", new[] { "127.0.0.1:9300" })
.Add("cluster.remote.cluster_two.skip_unavailable", true)
)
);这将在cluster_two (使用传输层端口)处配置一个名为127.0.0.1:9300的集群。
现在,在配置有客户端和远程集群的集群中进行搜索。
var searchResponse = client.Search<MyDocument>(s => s
.Index("index_name,cluster_two:index_name")
.Query(q => q
.MatchAll()
)
);,它在集群中的"index_name"索引中搜索http://example.com:9200,在远程集群中在127.0.0.1中搜索名为"index_name"的索引。
https://stackoverflow.com/questions/67500542
复制相似问题