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. python 正则进阶常用方法

    表达式 描述 正则表达式示例 符号 literal 匹配文本字符串的字面值literal foo rel1|rel2 匹配正则表达式rel1或rel2 foo|bar . 匹配任何字符(除了\n之外) ...

  2. Kaggle(2):验证和过分拟合

    目前看来,随机森林是比较常用且有效的分类算法.以下先简要介绍python中随机森林的使用方法,然后谈谈分类结果的准确度验证和过拟合等两个重要问题. 1.随机森林的参数 在Scikit learn中使用 ...

  3. day 03 变量与基本数据类型

    变量的命名规范 一:变量命名的大前提,应该能够反映出变量值所记录内容 1:变量名只能由数字,字母,下划线组成 2:变量名不能以数字开头 3:变量名不能使用系统的关键字,不然可能会报错 二:变量名的命名 ...

  4. ubuntu ssh 与 Samba安装

    ssh 安装:sudo apt-get install openssh-server 确认sshserver是否启动:ps -aux | grep ssh(/etc/init.d/ssh start, ...

  5. Ubuntu Core 网络配置

    /********************************************************************************* * Ubuntu Core 网络配 ...

  6. I.MX6 使用Ubuntu文件系统

    /********************************************************************************* * I.MX6 使用Ubuntu文 ...

  7. [LeetCode&Python] Problem 283. Move Zeroes

    Given an array nums, write a function to move all 0's to the end of it while maintaining the relativ ...

  8. markdown使用问题

    1.配置自定义的markdown.css https://github.com/sameer1994kiki/markdown-css 2.代码块 一行`` 多行 ``` <code>&l ...

  9. XXS level1

    level1 (1)查看PHP源码,发现可以通过调用window,alert()完成任务 window.alert = function() { confirm("完成的不错!") ...

  10. linux 系统 目录,以部分及相关命令

    linux 系统里的文件类型有: b. d.l. c. -  .s (块设备.目录.软连接.数字串设备.普通文件(文本.二进行文件).socket文件 ) ls 命令 ls -a  查看当前目录下的所 ...