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

ElasticSearch 7.x 索引创建mapping时指定type

ElasticSearch 7.x 索引创建mapping时指定type

ElasticSearch 7.x 索引创建mapping 问题场景:

ElasticSearch 6.x 版本支持创建mapping是直接指定type;ElasticSearch 7.x 版本不支持创建mapping是直接指定type,而是提供一个默认的type:_doc;如果想要在 ElasticSearch 7.x版本中创建mapping并指定type,则需要在URL后面添加参数:include_type_name=true;【注:这个参数默认是:include_type_name=false】

字段类型:(部分基础字段类型)

//简单数据类型:string、long、integer、short、byte、double、scaled_float、float、date、boolean、binary、keyword、text
//复杂数据类型:Array、object、nested
//地理位置类型:地理坐标类型(Geo-point datatype): geo_point 用于经纬度坐标;地理坐标类型(Geo-point datatype): geo_point 用于经纬度坐标;

1、创建默认type的mapping:
PUT  http://ip:port/索引名

{
    "mappings": {
            "properties": {
                "Field名" : {
                    "type" : "具体的字段数据类型"  
                }
            }
        }
}
2、创建自定义type的mapping:
PUT  http://ip:port/索引名?include_type_name=true
{
    "mappings": {
        "类型" : {   //----类型
            "properties": {
                "Field名" : {
                    "type" : "具体的字段数据类型"  
                }
            }
        }
    }
}
3、查看mapping:
GET http://ip:port/索引名/类型/_mapping
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/701627.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

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

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