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();
  • 相关阅读:
    [c language] getopt
    编程经典问题
    一些常用的正则表达式
    [Head First Python]6. summary
    Java多线程
    JVM运行原理
    Struts2---自定义拦截器
    SpringMVC框架初步
    测试基本问题
    自动化测试
  • 原文地址:https://www.cnblogs.com/xiaocandou/p/8127454.html
Copyright © 2011-2022 走看看