• 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]

    }

       

  • 相关阅读:
    spring filter and interceptor
    spring 与 swagger 2 的整合
    spring 异步操作
    图片延迟加载 jquery,lazyload.js 调用的demo
    一、Spring的第一个课时
    线程的基本了解
    HTTPS/HTTP监听常见问题
    Leetcode 118 杨辉三角
    HashSet的源码解释
    HashMap源码理解
  • 原文地址:https://www.cnblogs.com/liuqianli/p/8471020.html
Copyright © 2020-2023  润新知