zoukankan      html  css  js  c++  java
  • ElasticSearch(十三) Indices Administration

    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();
  • 相关阅读:
    第十周上机作业
    第九周上机作业
    第八周作业
    第八周上机作业
    第七周作业
    第七周上机作业
    第六周作业
    第六周上机作业
    第五周上机作业
    第四周作业
  • 原文地址:https://www.cnblogs.com/xiaocandou/p/8127454.html
Copyright © 2011-2022 走看看