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"
}
}
}
]
}
}
}
TransportClient 新建index,mappings dynamic_templates。的更多相关文章
- (转)Maven 项目新建index.jsp报错问题
原文:http://blog.csdn.net/dream_ll/article/details/52198656 最近用eclipse新建了一个maven项目,结果刚新建完成index.jsp页面就 ...
- 索引模板和动态索引模板 (Index Template和Dynamic Template)
相关阅读 Index Templates https://www.elastic.co/guide/en/elasticsearch/reference/7.1/indices-templates.h ...
- nexus私服update repair index索引失败解决方案(转)
转载地址:http://blog.csdn.net/first_sight/article/details/51559086 问题描述: 搭建Maven的Nexus私服仓库,一般安装完Nexus后,默 ...
- 新建maven项目
1.新建maven project 注意:勾上create a new simple project 2.填写相关信息, Grounp id为大项目名字,Artifact id为小项目的名字.注意:P ...
- 新建一个self hosted Owin+ SignalR Project(1)
OWIN是Open Web Server Interface for .Net 的首字母缩写,他的定义如下: OWIN在.NET Web Server 与Web Application之间定义了一套标 ...
- nodejs 新建项目
第一步: 新建工程-->选择nodejs-->creat 注意: 如果出错就使用第二步!! 第二步:建立express 模板的nodejs 点击下图的命令窗口,依次输入下面命令 命令: & ...
- vscode新建html,没有模板
首先,在文件夹下右击--新建--index.html 输入! 按tab键 完成!
- 开发微信公众平台--新建新浪云sae部署server
创建新浪云计算应用 申请账号 我们使用SAE新浪云计算平台作为server资源.而且申请PHP环境+MySQL数据库作为程序执行环境. 申请地址:百度搜sae ,使用新浪微博账号能够直接登录SAE,登 ...
- windows cmd 新建和删除文件
1.新建文件夹 # 新建App文件夹 md app # 或者使用 mkdir mkdir app 2.新建文件 # 进入App文件夹cd app # 新建 index.js 文件 type nul&g ...
随机推荐
- English (一)
Phrase do somebody a favour give sb a hand do something for sb come to sb aid 帮助某人 what can ...
- less中使用calc
css3中可以使用calc()来实现自适应布局 例如:width:“calc(100% - 25px)” width: calc(expression); ==> expression是一个表 ...
- FZU 2272 Frog 第八届福建省赛 (鸡兔同笼水题)
Problem Description Therearex frogs and y chicken in a garden. Kim found there are n heads and m leg ...
- 易混点总结--JS
1.defer与 async 的区别是: defer要等到整个页面在内存中正常渲染结束(DOM 结构完全生成,以及其他脚本执行完成),才会执行:async一旦下载完,渲染引擎就会中断渲染,执行这个脚本 ...
- js- caller、 callee
caller 返回一个对函数的引用,该函数调用了当前函数. functionName.caller functionName对象 是所执行函数的名称. 说明 对于函数来说 ...
- MyBatis insert操作返回主键
在使用MyBatis做持久层时,insert语句默认是不返回记录的主键值,而是返回插入的记录条数: Dao.java @Override public int insert(T record) { f ...
- char *s 和 char s[] 的区别
最近的项目中有不少c的程序,在与项目新成员的交流中发现,普遍对于char *s1 和 char s2[] 认识有误区(认为无区别),导致有时出现“难以理解”的错误.一时也不能说得很明白,网上也搜了一下 ...
- models.doc2vec – Deep learning with paragraph2vec
参考: 用 Doc2Vec 得到文档/段落/句子的向量表达 https://radimrehurek.com/gensim/models/doc2vec.html Gensim Doc2vec Tut ...
- 深入java final关键字
Java final关键字详解:https://blog.csdn.net/kuangay/article/details/81509164 深入java final关键字 用法注意点和JVM对其进行 ...
- HTML5的一些知识点
1.新增很多api,比如获取用户的地理位置的window.navigator.geoloaction,history,audio,video,canvas 2.websocket;websocket是 ...