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"
}
}
}
]
}
}
}

TransportClient 新建index,mappings dynamic_templates。的更多相关文章

  1. (转)Maven 项目新建index.jsp报错问题

    原文:http://blog.csdn.net/dream_ll/article/details/52198656 最近用eclipse新建了一个maven项目,结果刚新建完成index.jsp页面就 ...

  2. 索引模板和动态索引模板 (Index Template和Dynamic Template)

    相关阅读 Index Templates https://www.elastic.co/guide/en/elasticsearch/reference/7.1/indices-templates.h ...

  3. nexus私服update repair index索引失败解决方案(转)

    转载地址:http://blog.csdn.net/first_sight/article/details/51559086 问题描述: 搭建Maven的Nexus私服仓库,一般安装完Nexus后,默 ...

  4. 新建maven项目

    1.新建maven project 注意:勾上create a new simple project 2.填写相关信息, Grounp id为大项目名字,Artifact id为小项目的名字.注意:P ...

  5. 新建一个self hosted Owin+ SignalR Project(1)

    OWIN是Open Web Server Interface for .Net 的首字母缩写,他的定义如下: OWIN在.NET Web Server 与Web Application之间定义了一套标 ...

  6. nodejs 新建项目

    第一步: 新建工程-->选择nodejs-->creat 注意: 如果出错就使用第二步!! 第二步:建立express 模板的nodejs 点击下图的命令窗口,依次输入下面命令 命令: & ...

  7. vscode新建html,没有模板

    首先,在文件夹下右击--新建--index.html 输入! 按tab键 完成!

  8. 开发微信公众平台--新建新浪云sae部署server

    创建新浪云计算应用 申请账号 我们使用SAE新浪云计算平台作为server资源.而且申请PHP环境+MySQL数据库作为程序执行环境. 申请地址:百度搜sae ,使用新浪微博账号能够直接登录SAE,登 ...

  9. windows cmd 新建和删除文件

    1.新建文件夹 # 新建App文件夹 md app # 或者使用 mkdir mkdir app 2.新建文件 # 进入App文件夹cd app # 新建 index.js 文件 type nul&g ...

随机推荐

  1. 整理有关浏览器兼容性的css样式

    去掉IE自带的删除功能的×号 input::-ms-clear{display:none;} 去掉IE自带密码框的眼睛样式 input::-ms-reveal{display:none;}

  2. Go Storm Is Coming!

    goland---http://idea.youbbs.org .................................................................... ...

  3. IOS safari 浏览器 时间乱码(ios时间显示NaN) 问题解决

    问题一: 项目中遇到一个关于日期时间在ios中乱码在安卓中安然无恙的问题,焦躁了半天 问题如上图,通过用户选择的时间和当天的天数相加然后在ios上就是乱码 这个界面运用了日期类型的计算,当我们用Jav ...

  4. RESTful Service API 常见问题解决方案

    REST 风格的优秀设计应该像下面这些: - GET /users 获取所有用户 - GET /users/1234 获取ID为1234的用户 - POST /users 创建一个新用户 - PUT ...

  5. wewqe

    script.cscript_runreason(const struct interface *ifp, const char *reason)elen = (size_t)make_env(ifp ...

  6. java ip 正则表达式

    private static boolean isBoolIp(String ipAddress) { String ip = "(?:(?:25[0-5]|2[0-4][0-9]|[01] ...

  7. 【c++基础】字符数组和string相互转换

    字符数组转化成string类型char ch [] = "ABCDEFG";string str(ch);//也可string str = ch;或者char ch [] = &q ...

  8. linux命令行总结给自己看的版本

    复制 cp -r /src /dst 查看硬盘容量 df -h 重命名: mv /原来的 /现在的

  9. java-方法重写的注意事项

    1.父类中私有方法不能被重写.因为父类的私有方法子类根本就无法继承. 2.子类重写父类方法时,访问权限不能更低.最好就一致. 3.父类静态方法,子类也必须通过静态方法进行重写.其实这个算不上方法重写, ...

  10. html css input定位 文本框阴影 灰色不可编辑

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...