ElasticSearch添加索引
1. 编写索引内容
节点解释:
settings:配置信息
"number_of_replicas": 0 不需要备份(单节点的ElasticSearch使用)
"mappings": 映射内容
"dynamic":false 是否动态索引,这里使用的是false,表示索引的固定的,不需要修改。
"properties": 属性结构内容
"index":"true" 需要分词处理的结构
type对应的数据类型,text文本(长字符串),integer数字,date时间,keyword单词
elasticsearch 6.X版本的索引文件
{
"settings":{
"number_of_replicas":
},
"mappings":{
"house":{
"dynamic":false,
"properties":{
"houseId":{"type":"long"},
"title":{"type":"text", "index":"true"},
"price":{"type":"integer"},
"area":{"type":"integer"},
"createTime":{"type":"date","format":"strict_date_optional_time||epoch_millis"},
"lastUpdateTime":{"type":"date", "format":"strict_date_optional_time||epoch_millis"},
"cityEnName":{"type":"keyword"},
"regionEnName":{"type":"keyword"},
"direction":{"type":"integer"},
"distanceToSubway":{"type":"integer"},
"subwayLineName":{"type":"keyword"},
"subwayStationName":{"type":"keyword"},
"tags":{"type":"text"},
"district":{"type":"keyword"},
"description":{"type":"text", "index":"true"},
"layoutDesc":{"type":"text", "index":"true"},
"traffic":{"type":"text", "index":"true"},
"roundService": {"type": "text", "index": "true"},
"rentWay":{"type":"integer"}
}
}
}
}
elasticsearch 7.X版本的索引文件
{
"settings":{
"number_of_replicas": 0
},
"mappings":{
"dynamic":false,
"properties":{
"title":{"type":"text", "index":"true"},
"price":{"type":"integer"},
"area":{"type":"integer"},
"createTime":{"type":"date","format":"strict_date_optional_time||epoch_millis"},
"lastUpdateTime":{"type":"date", "format":"strict_date_optional_time||epoch_millis"},
"cityEnName":{"type":"keyword"},
"regionEnName":{"type":"keyword"},
"direction":{"type":"integer"},
"distanceToSubway":{"type":"integer"},
"subwayLineName":{"type":"keyword"},
"subwayStationName":{"type":"keyword"},
"tags":{"type":"text"},
"district":{"type":"keyword"},
"description":{"type":"text", "index":"true"},
"layoutDesc":{"type":"text", "index":"true"},
"traffic":{"type":"text", "index":"true"},
"roundService": {"type": "text", "index": "true"},
"rentWay":{"type":"integer"}
}
}
}
2. 创建索引
使用Postmen发送创建索引请求
(1)地址栏后半段是索引名称
(2)请求使用的PUT方式,选择Body,raw形式,采用JSON格式发送
创建成功的显示结果:
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "house"
}
在ElasticSearch-Head里查看结果:
3. 创建索引时的报错:
错误1:Root mapping definition has unsupported parameters
原因:ElasticSearch7.X之后的版本默认不在支持指定索引类型,默认索引类型是_doc(隐含:include_type_name=false),所以在mappings节点后面,直接跟properties就可以了。
问题2:Could not convert [title.index] to boolean
原因:也是新版本的问题,之前版本的index属性写法是"analyze",现在只能设置true, false, "true","false"
ElasticSearch添加索引的更多相关文章
- ElasticSearch+Kibana 索引操作( 附源码)
一 前言 ElasticiSearch 简介 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.Elastics ...
- ElasticSearch+Kibana 索引操作
ElasticSearch+Kibana 索引操作 一 前言 ElasticiSearch 简介 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引 ...
- elasticsearch的索引自动清理及自定义清理
近发现elasticsearch近期索引文件大的吓人,清理了下之前的索引文件,发现服务器性能大大的减轻了一半,想一直保留近一个月的索引文件,但是又不想每个月手动清楚,在此写了一个小脚本 查询索引: c ...
- ELK学习笔记之ElasticSearch的索引详解
0x00 ElasticSearch的索引和MySQL的索引方式对比 Elasticsearch是通过Lucene的倒排索引技术实现比关系型数据库更快的过滤.特别是它对多条件的过滤支持非常好,比如年龄 ...
- ElasticSearch6.0 Java API 使用 排序,分组 ,创建索引,添加索引数据,打分等(一)
ElasticSearch6.0 Java API 使用 排序,分组 ,创建索引,添加索引数据,打分等 如果此文章对你有帮助,请关注一下哦 1.1 搭建maven 工程 创建web工程 ...
- 为 Elasticsearch 添加中文分词,对比分词器效果
转自:http://keenwon.com/1404.html 为 Elasticsearch 添加中文分词,对比分词器效果 Posted in 后端 By KeenWon On 2014年12月12 ...
- solr 添加索引
添加索引模板: <add> <doc> <field name="employeeId">05991</field> <fie ...
- mysql 添加索引 mysql 创建索引
1.添加PRIMARY KEY(主键索引) mysql>ALTER TABLE `table_name` ADD PRIMARY KEY ( `column` ) 2.添加UNIQUE(唯一索引 ...
- .添加索引和类型,同时设定edgengram分词和charsplit分词
1.添加索引和类型,同时设定edgengram分词和charsplit分词 curl -XPUT 'http://127.0.0.1:9200/userindex/' -d '{ "se ...
随机推荐
- Flutter 1.17 新 Material motion 规范的预构建动画
老孟导读:在 Flutter 1.17 发布大会上,Flutter 团队还发布了新的 Animations 软件包,该软件包提供了实现新的 Material motion 规范的预构建动画. 软件包 ...
- YAML 语言教程与使用案例
YAML语言教程与使用案例,如何编与读懂写YAML文件. YAML概要 YAML 是 “YAML Ain’t a Markup Language”(YAML 不是一种标记语言)的递归缩写.在开发的这种 ...
- 卸载wsl子系统
1>在powershell中输入下面的代码 wslconfig /l #显示出你安装的列表. wslconfig /u debian #debian为上述列表中的名字 注销子系统 2>打开 ...
- JVM 专题十五:执行引擎
1. 执行引擎概述 1.1 执行引擎 1.2 概述 执行引擎是Java虚拟机的核心组成部分之一. 虚拟机是一个相对于“物理机”的概念,这两种机器都有代码执行能力,其区别是物理机的执行引擎是直接建立在处 ...
- Mysql基础(五):多表查询、pymysql模块
目录 数据库04 /多表查询.pymysql模块 1. 笛卡尔积 2. 连表查询 3. 子查询 4. pymysql模块 数据库04 /多表查询.pymysql模块 1. 笛卡尔积 将两表所有的数据一 ...
- Python面向对象05 /私有成员、类方法、静态方法、属性、isinstance/issubclass
Python面向对象05 /私有成员.类方法.静态方法.属性.isinstance/issubclass 目录 Python面向对象05 /私有成员.类方法.静态方法.属性.isinstance/is ...
- day7 python字符串的操作及方法
1.字符串 1.1 字符串的操作 # 1.字符串的拼接 strvar = "我爱" + "中国" # 2.字符串的重复 strvar = "今天下午2 ...
- Websphere修改web.xml不生效的解决办法(转)
在websphere下部署了一个java工程后,如果修改了web.xml文件,重新启动这个java工程发现websphere并没有自动加载web.xml文件,即修改后的web.xml并不起作用,除非重 ...
- GPO - AppLocker
AppLocker can help you: Define rules based on file attributes that persist across app updates, such ...
- OSCP Learning Notes - Exploit(6)
Antivirus Bypassing Tools: Kali Linux Detection Platform: https://www.virustotal.com/gui/home/upload ...