使用 NEST 设置 Elasticsearch routing_partition_size

Setting the Elasticsearch routing_partition_size using NEST

我正在使用 NEST 在 Elasticsearch 5.5 中创建索引。我需要在创建索引时更新 index.routing_partition_size 设置,但在 CreateIndexDescriptor 对象中看不到该设置。如何在 NEST 中指定此值?

我的设置目前是这样的:

return createIndexSelector
               //add analyzers and tokenizers
               .Settings(s => s
                   .NumberOfReplicas(2)
                    .NumberOfShards(40)
                    .Setting("refresh_interval", 10)
                   .Analysis(a => a
                       .Analyzers(az => az
                           .Custom("str_search_analyzer", c1 => GetCustomSearchAnalyzer())
                           .Custom("str_index_analyzer", c2 => GetCustomNgramAnalyzer()))
                       .Tokenizers(tz => tz
                           .NGram("autocomplete_ngram_tokenizer", ng => GetCustomAutoCompleteTokenizer()))))
              //add mappings for invoice and contact doc types
              .Mappings(m => m
                  .Map<DocType>(mDocType => mDocType .Properties(DocType.AddAllMappings)));

假设您使用的是 NEST 5.x,它在 IndexSettingsDescriptor

var createIndexResponse = await client.CreateIndexAsync("index", c => c
    .Settings(s => s.RoutingPartitionSize(10)));

产生以下请求

{
  "settings": {
    "index.routing_partition_size": 10
  }
}

希望对您有所帮助。