zoukankan      html  css  js  c++  java
  • TransportClient 新建index,mappings dynamic_templates。

    public void createIndex(TransportClient client, String index){
            CreateIndexRequest request = new CreateIndexRequest(index);
            String setting =""
                    +"{"
                    +"        "number_of_shards": 3,"
                    +"        "number_of_replicas": 1,"
                    +"        "search_analyzer": "ik_max_word""
                    +"}";
            String mapping ="{"
                    +"            "dynamic_templates": ["
                    +"                {"
                    +"                    "strings": {"
                    +"                        "match": "*","
                    +"                        "match_mapping_type": "string","
                    +"                        "mapping": {"
                    +"                            "type": "string","
                    +"                            "analyzer": "ik_max_word","
                    +"                            "fields": {"
                    +"                                "raw": {"
                    +"                                    "type": "string","
                    +"                                    "index": "not_analyzed","
                    +"                                    "ignore_above": 256"
                    +"                                }"
                    +"                            }"
                    +"                        }"
                    +"                    }"
                    +"                }"
                    +"            ]"
                    +"        }";
                request.settings(setting).mapping("_default_", mapping);
                client.admin().indices().create(request);
        }
    POST  http://192.168.1.12:9200/test
    
    {
        "settings": {
            "number_of_shards": 3,
            "number_of_replicas": 1,
            "search_analyzer": "ik_max_word"
        },
        "mappings": {
            "_default_": {
                "dynamic_templates": [
                    {
                        "strings": {
                            "match": "*",
                            "match_mapping_type": "string",
                            "mapping": {
                                "type": "string",
                                "analyzer": "ik_max_word",
                                "fields": {
                                    "raw": {
                                        "type": "string",
                                        "index": "not_analyzed",
                                        "ignore_above": 2560
                                    }
                                }
                            }
                        }
                    }
                ]
            }
        }
    }
    {
        "settings": {
            "number_of_shards": 5,
            "number_of_replicas": 1,
            "search_analyzer": "ik_max_word"
        },
        "mappings": {
            "_default_": {
                "dynamic_templates": [
                    {
                        "strings": {
                            "match": "*",
                            "unmatch": "id",
                            "match_mapping_type": "string",
                            "mapping": {
                                "type": "string",
                                "analyzer": "ik_max_word",
                                "fields": {
                                    "raw": {
                                        "type": "string",
                                        "index": "not_analyzed",
                                        "ignore_above": 2560
                                    }
                                }
                            }
                        }
                    },
                    {
                        "integers": {
                            "match": "id",
                            "mapping": {
                                "type": "integer"
                            }
                        }
                    }
                ]
            }
        }
    }
  • 相关阅读:
    c# 获取某个对象的[公有属性]的名称,类型,值
    iis10 HTTP 错误 500.19
    MVC 使用EF Code First数据迁移之添加字段
    emeditor 配置教程
    独立程序员如何赚钱致富
    win7/win8通过媒体流(DLNA技术)共享音乐照片和视频
    sails中文文档地址
    游戏碰撞的原理
    Android图片圆角效果
    Android 系统 root 破解原理分析 (续)
  • 原文地址:https://www.cnblogs.com/zzt-lovelinlin/p/8578701.html
Copyright © 2011-2022 走看看