MyElasticsearch
  • Introduction
  • 基本查询
  • 简介
  • 安装
    • Window下安装
  • 基础知识
    • 理解 document
    • 简单的集群管理
    • 简单实例:简单的curd操作
    • 简单实例:批量curd操作
    • 简单实例:多种搜索方式
    • 简单实例:聚合分析
    • 附录: _index,_type,_id,_source元数据
    • 附录:手动&自动生成document id
    • 附录:全量替换、强制创建、lazy delete机制
    • 附录:search timeout机制
    • _source && _all
  • 倒排索引
  • 查询附录
    • 分页搜索
    • multi-index&multi-type搜索模式
  • 查询
    • 测试数据
    • 简单查询
    • 基本查询
      • Term,Terms,Wildcard查询
        • Term查询
        • Terms查询
      • match相关查询
      • query_string查询
      • prefix前缀查询
      • fuzzy相关查询
        • fuzzy_like_this查询
        • fuzzy_like_this_field查询
        • fuzzy查询
    • 复合查询
  • groovy脚本
    • 执行部分更新(partial update)
  • 锁机制(悲观锁、乐观锁)
    • 基于_version乐观锁并发控制
    • 基于external version乐观锁并发控制
  • 查询方式
    • Query string方式
    • Query DSL 方式
    • query filter 方式
    • 各种query搜索语法
    • 多搜索条件组合查询
    • 检验不合法的Quqery查询
    • 搜索结果的排序规则
    • field索引两次来解决字符串排序
    • 使用scoll滚动搜索
    • 分词器
  • document mapping
    • 自动mapping带来的问题
    • field类型
    • mapping中的field type类型
    • 定制化dynamic mapping策略
  • 资料
  • 原理
    • 相关度评分TF&IDF算法
    • doc values 正排索引
  • 索引的CURD
  • 附录:基于scoll+bulk+索引别名实现零停机重建索引
Powered by GitBook
On this page
  • multivalue field
  • empty field
  • object field

Was this helpful?

  1. document mapping

field类型

multivalue field

{ "tags": [ "tag1", "tag2" ]}

empty field

null,[],[null]

object field

插入一条数据:

PUT /company/employee/1
{
  "address": {
    "country": "china",
    "province": "guangdong",
    "city": "guangzhou"
  },
  "name": "jack",
  "age": 27,
  "join_date": "2017-01-01"
}

查看自动创建的mapping

GET /company/_mapping/employee

返回结果:

address:object类型

{
  "company": {
    "mappings": {
      "employee": {
        "properties": {
          "address": {
            "properties": {
              "city": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "country": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "province": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          },
          "age": {
            "type": "long"
          },
          "join_date": {
            "type": "date"
          },
          "name": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    }
  }
}

刚才插入数据底层存储的方式:

{
    "name":            [jack],
    "age":          [27],
    "join_date":      [2017-01-01],
    "address.country":         [china],
    "address.province":   [guangdong],
    "address.city":  [guangzhou]
}

如果插入数据的json为:

{
    "authors": [
        { "age": 26, "name": "Jack White"},
        { "age": 55, "name": "Tom Jones"},
        { "age": 39, "name": "Kitty Smith"}
    ]
}

底层会变成:

{
    "authors.age":    [26, 55, 39],
    "authors.name":   [jack, white, tom, jones, kitty, smith]
}
Previous自动mapping带来的问题Nextmapping中的field type类型

Last updated 6 years ago

Was this helpful?