IndicesAdminClient indicesAdminClient = client.admin().indices();

Create Index
client.admin().indices().prepareCreate("twitter").get();
   Index Settings
client.admin().indices().prepareCreate("twitter")
        .setSettings(Settings.builder()             
                .put("index.number_of_shards", 3)
                .put("index.number_of_replicas", 2)
        )
        .get();       

static final Builder builder = Settings.builder().put("index.analysis.search_analyzer.default.type", "ik_smart")
.put("index.analysis.analyzer.default.type", "ik_max_word").put("index.mapping.total_fields.limit", 30000);

index.mapping.total_fields.limit 默认值:1000

Refresh

client.admin().indices().prepareRefresh().get(); 
client.admin().indices()
        .prepareRefresh("twitter")               
        .get();
client.admin().indices()
        .prepareRefresh("twitter", "company")   
        .get();

Get Settings

GetSettingsResponse response = client.admin().indices()
        .prepareGetSettings("company", "employee").get();                           
for (ObjectObjectCursor<String, Settings> cursor : response.getIndexToSettings()) { 
    String index = cursor.key;                                                      
    Settings settings = cursor.value;                                               
    Integer shards = settings.getAsInt("index.number_of_shards", null);             
    Integer replicas = settings.getAsInt("index.number_of_replicas", null);         
}

Update Indices Settings

client.admin().indices().prepareUpdateSettings("twitter")   
        .setSettings(Settings.builder()                     
        .put("index.number_of_replicas", 0)
     ).get();

 

相关文章:

  • 2021-09-17
  • 2021-12-14
  • 2022-01-22
  • 2021-11-30
  • 2021-11-26
  • 2021-12-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2022-12-23
  • 2022-03-07
  • 2021-07-22
  • 2021-05-21
相关资源
相似解决方案