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 ...
随机推荐
- RESTful Service API 常见问题解决方案
REST 风格的优秀设计应该像下面这些: - GET /users 获取所有用户 - GET /users/1234 获取ID为1234的用户 - POST /users 创建一个新用户 - PUT ...
- js Promise fetch demo
<html> <head> <title></title> </head> <body> </body> <s ...
- Caution: request is not finished yet
/********************************************************************** * Caution: request is not fi ...
- busybox devmem 直接获取、修改内存信息
/********************************************************************** * busybox devmem 直接获取.修改内存信息 ...
- 海康抓拍机SDK开发
前言 项目采购的海康威视的抓拍机,需要首先获取抓拍图片,之后基于抓拍图片进行图像处理.本文基于海康SDK开发文档,按照开发步骤,咨询海康技术人员,现将开发过程记录如下. 主要过程的c++代码: /** ...
- 牛客OI赛制测试赛2
A题: https://www.nowcoder.com/acm/contest/185/A 链接:https://www.nowcoder.com/acm/contest/185/A来源:牛客网 题 ...
- 【牛客练习赛22 C】
https://www.nowcoder.com/acm/contest/132/C 题目大意:在n个区间中取出n个数,相加的和一共会出现多少种结果. 题目分析:对于这种挑选数字相加,由于每一步不同的 ...
- ★ MYSQL隔离级别 通俗理解 + mysql、oracle默认事务隔离级别
★ 脏读 : 读取了前一事务 未提交 的数据 ; 不可重复读 : 读取了前一事务 提交 的数据: ★ 幻读 与 不可重复读 common :都是读取了另一条已经提交的事务(这点与脏读不 ...
- [原]android 链接错误
由于没有使用NDK的makefile, 而是把NDK的toolchain集成到现有的build system, 所以出现了诡异的错误: unsupported dynamic reloc R_ARM_ ...
- linux服务器的日志管理
消息紧急程度排行 emerg:该系统不可用 alert:需要立即修改 crit:紧急情况 err:错误信息 warning:预警信息 notice:具有重要性的普通条件 info:提供信息的消息 de ...