zoukankan      html  css  js  c++  java
  • 46.object类型

    主要知识点

    1field分类

    2、object field类型的存储

    一、field类型分类

    1multivalue field

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

    建立索引时与string是一样的,数据类型不能混

       

    2empty field

       

    null[][null]

       

    3object field

    es插入以下数据

    PUT /company/employee/1

    {

    "address": {

    "country": "china",

    "province": "guangdong",

    "city": "guangzhou"

    },

    "name": "jack",

    "age": 27,

    "join_date": "2017-01-01"

    }

       

    其中address就是object类型,也就是address里面是一个json格式的数据。

    再执行GET /company/_mapping/employee,结果是:

    {

    "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

    }

    }

    }

    }

    }

    }

    }

    }

    二、object field类型的存储

    head进行查看,es是按以下方式进行存储:

    {

    "name": "jack",

    "age": 27,

    "join_date":"2017-01-01",

    "address.country":"china",

    "address.province": "guangdong",

    "address.city":"guangzhou"

    }

    如果是更复杂的数据,如下面这条

    {

    "authors": [

    { "age": 26, "name": "Jack White"},

    { "age": 55, "name": "Tom Jones"},

    { "age": 39, "name": "Kitty Smith"}

    ]

    }

    在es内部存储方式如下:

    {

    "authors.age": [26, 55, 39],

    "authors.name": [jack, white, tom, jones, kitty, smith]

    }

       

  • 相关阅读:
    Mapbox GL JS使用小结(一)
    js 跳转链接的几种方式
    使用iis 部署 .net项目遇到的问题
    ROS 导入示例程序并建立工程运行
    C# WPF程序增加终端串口打印调试信息
    C# 继承方法重写调用测试
    C# 迭代器实现
    C# 引用和值都按照引用传递(其实传递的就是指针)
    C# string引用类型参数不变性
    C# 值类型和引用类型
  • 原文地址:https://www.cnblogs.com/liuqianli/p/8471020.html
Copyright © 2011-2022 走看看