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();
  • 相关阅读:
    Web应用程序并发问题处理的一点小经验
    *.pvr.ccz文件还原成png格式
    在python 中is和= = 的区别
    pyhton,数据类型
    python,序列化
    python, 操作文件和目录
    python文件,字符串,二进制的读写
    io编程,python
    python,错误、调试和测试
    python,多线程
  • 原文地址:https://www.cnblogs.com/xiaocandou/p/8127454.html
Copyright © 2011-2022 走看看