Search code examples
elasticsearchnest

Setting the Elasticsearch routing_partition_size using NEST


I'm using NEST to create an index in Elasticsearch 5.5. I need to update the index.routing_partition_size setting on index creation but don't see that setting in the in CreateIndexDescriptor object. How can I specify what this value is in NEST?

My settings currently looks like this:

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)));

Solution

  • Assuming you are using NEST 5.x, it's under IndexSettingsDescriptor

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

    Which produces the following request

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

    Hope that helps.