栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

ES如何创建索引

ES如何创建索引

环境

环境:ES 6.8.10
os:Centos 7.8.2003 (Core)

创建索引

1、创建新的索引(index)
PUT indexTest001

2、索引设置
ES 默认提供了好多索引配置选项,参考https://www.elastic.co/guide/en/elasticsearch/reference/5.6/index-modules.html
修改索引设置参考:https://blog.csdn.net/qq_15958689/article/details/79524291

3、创建mapping
先看下刚刚创建的索引的mapping:
GET indextest001/_mapping

由上图显示,新建的索引中,mapping是一个空集,我们要创建这个index的mapping

```xml
POST indextest001/product/_mapping?pretty 

    {"product":{"properties":{"title":{"type":"text","store":"true"},"description":{"type":"text","index":"false"},"price":{"type":"double"},"onSale":{"type":"boolean"},"type":{"type":"integer"},"createDate":{"type":"date"}}}}
![在这里插入图片描述](https://img-blog.csdnimg.cn/1b62d3048241473eb6aa3b3a73059ed0.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6KW_57Gzcw==,size_20,color_FFFFFF,t_70,g_se,x_16)


创建完再次查看
![在这里插入图片描述](https://img-blog.csdnimg.cn/6b114c12f8da45e1bafe922ad1bebad9.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6KW_57Gzcw==,size_20,color_FFFFFF,t_70,g_se,x_16)
4、插入数据

POST indextest001/product
{undefined
  "title": "test title 001",
  "description": "es test 001 ",
  "price": 1.6,
  "onSale": "true",
  "type": 2,
  "createDate": "2021-01-08"
}

 然后查询一下所有数据,默认为match_all
 GET indextest001/product/



[参考文章](https://blog.csdn.net/qq_15958689/article/details/79524291)
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/700541.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号