Notice: 函数 WP_Scripts::localize 的调用方法不正确$l10n 参数必须是一个数组。若要将任意数据传递给脚本,请改用 wp_add_inline_script() 函数。 请查阅调试 WordPress来获取更多信息。 (这个消息是在 5.7.0 版本添加的。) in /data/www/appblog/wp-includes/functions.php on line 6131

ElasticSearch 7 学习(3)映射的介绍与使用

  • type: text 可分词
  • type: keyword 不可分词

创建Mapping PUT请求

  • 请求
localhost:9200/nba/_mapping
  • 请求体
{
    "properties":{    //字段的信息
        "name":{
            "type":"text"
        },
        "team_name":{
            "type":"text"
        },
        "position":{
            "type":"keyword"
        },
        "play_year":{
            "type":"keyword"
        },
        "jerse_no":{
            "type":"keyword"
        }
    }
}
  • 响应
{
    "acknowledged": true
}

查看Mapping信息 GET请求

  • 请求
localhost:9200/nba/_mapping
  • 响应
{
    "nba": {
        "mappings": {
            "properties": {
                "jerse_no": {
                    "type": "keyword"
                },
                "name": {
                    "type": "text"
                },
                "play_year": {
                    "type": "keyword"
                },
                "position": {
                    "type": "keyword"
                },
                "team_name": {
                    "type": "text"
                }
            }
        }
    }
}

批量获取Mapping信息 GET请求

  • 请求
localhost:9200/nba,cba/_mapping
  • 响应
{
    "nba": {
        "mappings": {
            "properties": {
                "jerse_no": {
                    "type": "keyword"
                },
                "name": {
                    "type": "text"
                },
                "play_year": {
                    "type": "keyword"
                },
                "position": {
                    "type": "keyword"
                },
                "team_name": {
                    "type": "text"
                }
            }
        }
    },
    "cba": {
        "mappings": {}
    }
}

获取所有Mapping信息第一种方式 GET请求

  • 请求
localhost:9200/_mapping
  • 响应
{
    "nba": {
        "mappings": {
            "properties": {
                "jerse_no": {
                    "type": "keyword"
                },
                "name": {
                    "type": "text"
                },
                "play_year": {
                    "type": "keyword"
                },
                "position": {
                    "type": "keyword"
                },
                "team_name": {
                    "type": "text"
                }
            }
        }
    },
    "cba": {
        "mappings": {}
    }
}

获取所有Mapping信息第二种方式 GET请求

  • 请求
localhost:9200/_all/_mapping
  • 响应
{
    "nba": {
        "mappings": {
            "properties": {
                "jerse_no": {
                    "type": "keyword"
                },
                "name": {
                    "type": "text"
                },
                "play_year": {
                    "type": "keyword"
                },
                "position": {
                    "type": "keyword"
                },
                "team_name": {
                    "type": "text"
                }
            }
        }
    },
    "cba": {
        "mappings": {}
    }
}

增加Mapping字段 POST请求

Mapping 只可增加字段不可修改字段

  • 请求
localhost:9200/nba/_mapping
  • 请求体
{
    "properties":{    
        "name":{
            "type":"text"
        },
        "team_name":{
            "type":"text"
        },
        "position":{
            "type":"keyword"
        },
        "play_year":{
            "type":"keyword"
        },
        "jerse_no":{
            "type":"keyword"
        },
        "country":{  // 增加的国家字段
            "type":"keyword"
        }
    }
}
  • 响应
{
    "acknowledged": true
}
上一篇 ElasticSearch 7 学习(2)索引基本操作
下一篇 ElasticSearch 7 学习(4)文档的增删改查