es创建索引的格式,并初始化数据
学习了:https://www.imooc.com/video/15759
1, 创建格式
POST 127.0.0.1:9200/book/novel/_mappings
{
"novel":{
"properties": {
"word_count": {
"type": "integer"
},
"author": {
"type": "keyword"
},
"title": {
"type": "text"
},
"publish_date": {
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis",
"type": "date"
}
}
}
}
2,插入数据
PUT 方法进行数据插入,插入同时指定id
127.0.0.1:9200/book/novel/5
{
"author": "王五",
"title": "菜谱",
"word_count": 5000,
"publish_date": "2002-10-01"
}
127.0.0.1:9200/book/novel/2
{
"author": "李三",
"title": "Java入门",
"word_count": 2000,
"publish_date": "2010-10-01"
}
127.0.0.1:9200/book/novel/8
{
"author": "瓦力",
"title": "ElasticSearch入门",
"word_count": 3000,
"publish_date": "2017-08-20"
}
127.0.0.1:9200/book/novel/9
{
"author": "很胖的瓦力",
"title": "ElasticSearch精通",
"word_count": 3000,
"publish_date": "2017-08-15"
}
127.0.0.1:9200/book/novel/10
{
"author": "牛魔王",
"title": "芭蕉扇",
"word_count": 1000,
"publish_date": "2000-10-01"
}
127.0.0.1:9200/book/novel/2
{
"author": "李三",
"title": "Java入门",
"word_count": 2000,
"publish_date": "2010-10-01"
}
127.0.0.1:9200/book/novel/4
{
"author": "李四",
"title": "ElasticSearch大法好",
"word_count": 1000,
"publish_date": "2017-08-01"
}
127.0.0.1:9200/book/novel/6
{
"author": "赵六",
"title": "剑谱",
"word_count": 10000,
"publish_date": "1997-01-01"
}
127.0.0.1:9200/book/novel/1
{
"author": "张三",
"title": "移魂大法",
"word_count": 1000,
"publish_date": "2000-10-01"
}
127.0.0.1:9200/book/novel/7
{
"author": "张三丰",
"title": "太极拳",
"word_count": 1000,
"publish_date": "1997-01-01"
}
127.0.0.1:9200/book/novel/3
{
"author": "张四",
"title": "python入门",
"word_count": 2000,
"publish_date": "2005-10-01"
}
127.0.0.1:9200/book/novel/11
{
"author": "孙悟空",
"title": "七十二变",
"word_count": 1000,
"publish_date": "2000-10-01"
}
127.0.0.1:9200/book/novel/12
{
"author": "瓦力",
"title": "瓦力教我们学ElasticSearch",
"word_count": 1000,
"publish_date": "2017-08-01"
}
1, 创建格式
POST 127.0.0.1:9200/book/novel/_mappings
{
"novel":{
"properties": {
"word_count": {
"type": "integer"
},
"author": {
"type": "keyword"
},
"title": {
"type": "text"
},
"publish_date": {
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis",
"type": "date"
}
}
}
}
2,插入数据
PUT 方法进行数据插入,插入同时指定id
127.0.0.1:9200/book/novel/5
{
"author": "王五",
"title": "菜谱",
"word_count": 5000,
"publish_date": "2002-10-01"
}
127.0.0.1:9200/book/novel/2
{
"author": "李三",
"title": "Java入门",
"word_count": 2000,
"publish_date": "2010-10-01"
}
127.0.0.1:9200/book/novel/8
{
"author": "瓦力",
"title": "ElasticSearch入门",
"word_count": 3000,
"publish_date": "2017-08-20"
}
127.0.0.1:9200/book/novel/9
{
"author": "很胖的瓦力",
"title": "ElasticSearch精通",
"word_count": 3000,
"publish_date": "2017-08-15"
}
127.0.0.1:9200/book/novel/10
{
"author": "牛魔王",
"title": "芭蕉扇",
"word_count": 1000,
"publish_date": "2000-10-01"
}
127.0.0.1:9200/book/novel/2
{
"author": "李三",
"title": "Java入门",
"word_count": 2000,
"publish_date": "2010-10-01"
}
127.0.0.1:9200/book/novel/4
{
"author": "李四",
"title": "ElasticSearch大法好",
"word_count": 1000,
"publish_date": "2017-08-01"
}
127.0.0.1:9200/book/novel/6
{
"author": "赵六",
"title": "剑谱",
"word_count": 10000,
"publish_date": "1997-01-01"
}
127.0.0.1:9200/book/novel/1
{
"author": "张三",
"title": "移魂大法",
"word_count": 1000,
"publish_date": "2000-10-01"
}
127.0.0.1:9200/book/novel/7
{
"author": "张三丰",
"title": "太极拳",
"word_count": 1000,
"publish_date": "1997-01-01"
}
127.0.0.1:9200/book/novel/3
{
"author": "张四",
"title": "python入门",
"word_count": 2000,
"publish_date": "2005-10-01"
}
127.0.0.1:9200/book/novel/11
{
"author": "孙悟空",
"title": "七十二变",
"word_count": 1000,
"publish_date": "2000-10-01"
}
127.0.0.1:9200/book/novel/12
{
"author": "瓦力",
"title": "瓦力教我们学ElasticSearch",
"word_count": 1000,
"publish_date": "2017-08-01"
}
es创建索引的格式,并初始化数据的更多相关文章
-
Elasticsearch(ES) 创建索引
欢迎关注笔者的公众号: 小哈学Java, 每日推送 Java 领域干货文章,关注即免费无套路附送 100G 海量学习.面试资源哟!! 个人网站: https://www.exception.site/ ...
-
Es创建索引、设置和修改Mapping
Http接口操作示例如下: 1.创建索引: 2.删除索引: 3.创建mapping: 4.查看mapping:
-
django “如何”系列8:如何为模型提供初始化数据
当你第一次配置一个app的时候,有时候使用硬编码的数据去预填充你的数据库是非常有用的.这里有几个你可以让django自动创建这些数据的方法:你可以提供固定格式的初始化数据或者提供通过SQL初始化数据. ...
-
mysql 创建索引和删除索引
索引的创建可以在CREATE TABLE语句中进行,也可以单独用CREATE INDEX或ALTER TABLE来给表增加索引.删除索引可以利用ALTER TABLE或DROP INDEX语句来实现. ...
-
oracle 创建索引
一.索引简介 1.索引相当于目录 2.索引是通过一组排序后的索引键来取代默认的全表扫描检索方式,从而提高检索效率. 3.索引的创建要适度,多了会影响增删改的效率,少了会影响查询的效率,索引最好创建在取 ...
-
mysql索引 ->;创建索引、修改索引、删除索引的命令语句
查看表中已经存在 index:show index from table_name; 创建和删除索引索引的创建可以在CREATE TABLE语句中进行,也可以单独用CREATE INDEX或ALTER ...
-
mysql——创建索引、修改索引、删除索引的命令语句
查看表中已经存在 index:show index from table_name; 创建和删除索引索引的创建可以在CREATE TABLE语句中进行,也可以单独用CREATE INDEX或ALTER ...
-
mysql创建索引-----高性能(五)
转载地址:https://www.cnblogs.com/llzhang123/p/7889382.html 索引的创建可以在CREATE TABLE语句中进行,也可以单独用CREATE INDEX或 ...
-
.net下灰度模式图像在创建Graphics时出现:无法从带有索引像素格式的图像创建graphics对象 问题的解决方案。
在.net下,如果你加载了一副8位的灰度图像,然后想向其中绘制一些线条.或者填充一些矩形.椭圆等,都需要通过Grahpics.FromImage创建Grahphics对象,而此时会出现:无法从带有索引 ...
随机推荐
-
React Native知识7-TabBarIOS组件
一:简介 两个TabBarIOS和TabBarIOS.Item组件可以实现页面Tab切换的功能,Tab页面切换的架构在应用开发中还是非常常见的.如:腾讯QQ,淘宝,美团外卖等等 二:TabBarIOS ...
-
Mybaits学习总结2
http://www.cnblogs.com/xdp-gacl/p/4262895.html 继续参考这篇文章写Mybaits学习总结 上一章,我修改了编码,统一为UTF8之后,便没有编码错误 < ...
-
[转]VS2005 Debug时提示";没有找到MSVCR80D.dll";的解决办法
总结各种解决方法如下: 原因:(不知道在说啥)由于VS.net 2005 采用了一种新的DLL方案,搞成一个exe还要配有一个manifest文件(一般在嵌入文件里了,所以看不到,不过也可以不嵌入,这 ...
-
jquery.validate.js使用id验证控件
jquery.validate.js默认的是元素的name. 例如:<input name="username" id="username" size=& ...
-
tableView创建方法调用的研究
当两个section的cell数量都为5的时候,方法的调用顺序: -[ViewController numberOfSectionsInTableView:] -[ViewController tab ...
-
SublimeText用FileHeader给代码文件生成头部注释
https://github.com/shiyanhui/FileHeader 修改的模板在这个路径下:C:\Users\[USERNAME]\AppData\Roaming\Sublime Text ...
-
C++中const的实现机制深入分析
via:http://www.jb51.net/article/32336.htm C语言以及C++语言中的const究竟表示什么?其具体的实现机制又是如何实现的呢?本文将对这两个问题进行一些分析,需 ...
-
sql server2005安装时报 ‘服务无法启动’
SQL server服务无法启动的原因分析: 在安装SQL 2005标准版(不多于四个CPU)和企业版(无限制)时,CPU的总核数必须是2的n次方.即核心数为1,2,4,8,16,32依次类推.因BL ...
-
zabbix proxy
ProxyMode=0 Server=zabbix-server的IPHostname=zabbix proxy(跟在zabbixWED网页建立代理proxies名称一样) LogFile=/data ...
-
如何让.net程序支持TLS1.2
1.将.Net FrameWork设置成4.6以上版本 2.在需要的类中引入命名空间 using System.Net; 3.在程序调用接口(如支付)的地方,加一段代码即可 System.Net.Se ...