美文网首页
4、elasticsearch映射mapping

4、elasticsearch映射mapping

作者: 安安汐而 | 来源:发表于2018-09-07 16:00 被阅读0次

1、elasticsearch安装
2、elasticsearch概念
3 、elasticsearch的crud、批量操作
4、elasticsearch映射mapping
5、elasticsearch查询

映射

映射是创建索引的时候,可以预先定义字段的类型以及相关属性

elasticsearch会根据JSON源数据的数据基础类型猜测你想要的字段映射。将输入的数据转变成可搜索的索引项。Mapping就是根据我们自己定义的字段的数据类型,同时告诉Elasticsearch如何索引数据以及是否可以被搜索。

作用:会让索引建立的更加细致和完善
类型:静态映射和动态映射

内置类型:

文本类型: text,keyword(text会被分词等解析、可搜索)
数字类型:long,integer,short,byte,double,float
日期:date
bool类型:boolean
binary类型:binary
复制类型:object,nested
geo类型:geo-point,geo-shape
专业类型:ip,competion

属性:

图片.png
PUT lagou
{
  "mappings": {
    "job":{
      "properties":{
        "title":{
          "type": "text"
        },
        "salary_min": {
          "type": "integer"
        },
        "city":{
          "type":"keyword"
        },
        "company":{
          "properties":{
            "name":{
              "type": "text"
            },
            "company_addr":{
              "type":"text"
            },
            "employee_count":{
              "type":"integer"
            }
          }
        },
        "publish_date":{
          "type":"date",
          "format":"yyyy-MM-dd"
        },
        "comments":{
          "type": "integer"
        }
      }
    }
  }
}

相关文章

网友评论

      本文标题:4、elasticsearch映射mapping

      本文链接:https://www.haomeiwen.com/subject/gepcgftx.html