gpt4 book ai didi

c# - 定义应使用多个节点创建哪个节点索引

转载 作者:行者123 更新时间:2023-12-03 00:44:51 28 4
gpt4 key购买 nike

这是我的连接文件

         this IServiceCollection services, IConfiguration configuration)
{
var EsNode = configuration["elasticsearch:AcqDataUrl"];

var NCTNode = configuration["elasticsearch:NCTDataUrl"];

var nodes = new Uri[]
{
new Uri(EsNode),
new Uri(NCTNode)
};

var pool = new StaticConnectionPool(nodes);
var connection = new ConnectionSettings(pool).DisableDirectStreaming();
EsClient = new ElasticClient(connection);

var settings = new IndexSettings { NumberOfReplicas = 1, NumberOfShards = 2 };

var indexConfig = new IndexState
{
Settings = settings
};

在这里我要定义应该在哪个节点索引上创建它正在第一个节点上创建索引的多个节点之间的nodes [0]或nodes [1]
           {
EsClient.Indices.Create(configuration["elasticsearch:AcquiringIndex"], c => c
.InitializeUsing(indexConfig)
.Mappings(m => m.Map<Acquirer>(mp => mp.AutoMap())));

}
if (!EsClient.Indices.Exists(configuration["elasticsearch:ElasticR&DIndex"]).Exists)
{
EsClient.Indices.Create(configuration["elasticsearch:ElasticR&DIndex"], c => c
.InitializeUsing(indexConfig)
.Mappings(m => m.Map<Employee>(mp => mp.AutoMap())));

}
if (!EsClient.Indices.Exists(configuration["elasticsearch:NetConnectTransactionIndex"]).Exists)
{
EsClient.Indices.Create(configuration["elasticsearch:NetConnectTransactionIndex"], c => c
.InitializeUsing(indexConfig)
.Mappings(m => m.Map<TransactionDto>(mp => mp.AutoMap())));

}

services.AddSingleton<IElasticClient>(EsClient);

}
我想从Singleton开始传递两个连接,并在Startup.cs中调用它,因为它将在继承的类中使用Controller进行进一步查询

最佳答案

如果创建的索引具有2个主分片和1个副本,并且有2个数据节点,则两个节点上将分别具有分片[0]和分片[1](因为每个分片都有2个副本-副本无法站立同一节点)
接收CREATE INDEX API调用的节点与确定分片的位置无关

关于c# - 定义应使用多个节点创建哪个节点索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63939755/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com