ES之文档映射

ES之文档映射,第1张

ES之文档映射 ES之文档映射

一、索引文档映射关系创建
【PUT】请求:http://127.0.0.1:9200/user-info/_mapping,参数如下

{
    "properties" : {
        "name" : {
            "type" : "text",
            "index" : true
        },
        "sex" : {
            "type" : "keyword",
            "index" : true
        },
        "phoneNum" : {
            "type" : "keyword",
            "index" : false
        }
    }
}

user-info为提前创建好的索引名称(可以【PUT】请求:http://127.0.0.1:9200/user-info进行索引创建)
index表示该字段可以索引查询
type为字段类型,有多种,可参考 https://blog.csdn.net/ZYC88888/article/details/83059040

返回结果如下

{
    "acknowledged": true
}

二、查询索引文档映射关
【GET】请求:http://127.0.0.1:9200/user-info/_mapping
返回结果如下

{
    "user-info": {
        "mappings": {
            "properties": {
                "name": {
                    "type": "text"
                },
                "phoneNum": {
                    "type": "keyword",
                    "index": false
                },
                "sex": {
                    "type": "keyword"
                }
            }
        }
    }
}

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5689046.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-17
下一篇2022-12-17

发表评论

登录后才能评论

评论列表(0条)

    保存