码迷,mamicode.com
首页 > 移动开发 > 详细

elasticsearch入门使用(二) Mapping + field type字段类型

时间:2018-03-12 21:02:41      阅读:3442      评论:0      收藏:0      [点我收藏+]

标签:html   geo   text   table   cto   address   code   com   gpo   

Elasticsearch Reference [6.2] ? Mapping
参考官方英文文档 https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html

Mapping 是定义文档及其包含的字段如何存储和编制索引的过程,每个索引都有一个映射类型,用于确定文档将如何编制索引。

Meta-fields
包括文档的_index,_type,_id和_source字段

es字段数据类型
https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html

  1. 字符串类型
    textkeyword
  2. 数值类型
    long, integer, short, byte, double, float, half_float, scaled_float
  3. 日期类型
    date
  4. 布尔值类型
    boolean
  5. 二进制类型
    binary
  6. 范围类型
    integer_range, float_range, long_range, double_range, date_range
  7. Array数据类型(Array不需要定义特殊类型)

    [ "one", "two" ]
    [ 1, 2 ]
    [{ "name": "Mary", "age": 12 },{ "name": "John", "age": 10}]
  8. Object数据类型 (json嵌套)

    { 
      "region": "US",
      "manager": { 
    "age":     30,
    "name": { 
      "first": "John",
      "last":  "Smith"
    }
      }
    }
  9. 地理数据类型
    Geo-pointGeo-Shape(比较复杂,参考官网文档,一般用Geo-point就可以了)
  10. 特殊数据类型
    ip(IPv4 and IPv6 addresses)
    completion(自动完成/搜索)
    token_count (数值类型,分析字符串,索引的数量)
    murmur3 (索引时计算字段值的散列并将它们存储在索引中的功能。 在高基数和大字符串字段上运行基数聚合时有很大帮助)
    join (同一索引的文档中创建父/子关系)

以下是常用的参数类型定义&赋值demo

类型 参数定义 赋值
text "name":{"type":"text"} "name": "zhangsan"
keyword "tags":{"type":"keyword"} "tags": "abc"
date "date":{"type": "date"} "date":"2015-01-01T12:10:30Z"
long "age":{"type":"long"} "age" :28
double "score":{"type":"double"} "score":98.8
boolean "isgirl": { "type": "boolean" } "isgirl" :true
ip "ip_addr":{"type":"ip"} "ip_addr": "192.168.1.1"
geo_point "location": {"type":"geo_point"} "location":{"lat":40.12,"lon":-71.34}

Mapping parameters

https://www.elastic.co/guide/en/elasticsearch/reference/6.2/mapping-params.html

mapping parameters 备注
analyzer
normalizer
boost
coerce
copy_to
doc_values
dynamic
enabled
fielddata
eager_global_ordinals
format
ignore_above
ignore_malformed
index_options
index
fields
norms
null_value
position_increment_gap
properties
search_analyzer
similarity
store
term_vector

elasticsearch入门使用(二) Mapping + field type字段类型

标签:html   geo   text   table   cto   address   code   com   gpo   

原文地址:https://www.cnblogs.com/nickchou/p/8549886.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!