129、商城业务-商品上架-nested数据类型场景

PUT product
{
  "mappings": {
    "properties": {
      "skuId": {
        "type": "long"
      },
      "spuId": {
        "type": "keyword"
      },
      "skuTitle": {
        "type": "text",
        "analyzer": "ik_smart"
      },
      "skuPrice": {
        "type": "keyword"
      },
      "skuImg": {
        "type": "keyword",
        "index": false,
        "doc_values": false
      },
      "saleCount": {
        "type": "long"
      },
      "hasStock": {
        "type": "boolean"
      },
      "hotScore": {
        "type": "long"
      },
      "brandId": {
        "type": "long"
      },
      "catalogId": {
        "type": "long"
      },
      "brandName": {
        "type": "keyword",
        "index": false,
        "doc_values": false
      },
      "brandImg": {
        "type": "keyword",
        "index": false,
        "doc_values": false
      },
      "catalogName": {
        "type": "keyword",
        "index": false,
        "doc_values": false
      },
      "attrs": {
        "type": "nested",
        "properties": {
          "attrId": {
            "type": "long"
          },
          "attrName": {
            "type": "keyword",
            "index": false,
            "doc_values": false
          },
          "attrValue": {
            "type": "keyword"
          }
        }
      }
    }
  }
}

https://www.elastic.co/guide/en/elasticsearch/reference/7.9/nested.html  

129、商城业务-商品上架-nested数据类型场景_第1张图片

PUT my-index-000001/_doc/1
{
  "group" : "fans",
  "user" : [ 
    {
      "first" : "John",
      "last" :  "Smith"
    },
    {
      "first" : "Alice",
      "last" :  "White"
    }
  ]
}

129、商城业务-商品上架-nested数据类型场景_第2张图片

129、商城业务-商品上架-nested数据类型场景_第3张图片

GET my-index-000001/_search
{
  "query": {
    "bool": {
      "must": [
        { "match": { "user.first": "Alice" }},
        { "match": { "user.last":  "Smith" }}
      ]
    }
  }
}

129、商城业务-商品上架-nested数据类型场景_第4张图片

129、商城业务-商品上架-nested数据类型场景_第5张图片

是text的,不是嵌入式的

129、商城业务-商品上架-nested数据类型场景_第6张图片

 

129、商城业务-商品上架-nested数据类型场景_第7张图片

129、商城业务-商品上架-nested数据类型场景_第8张图片

129、商城业务-商品上架-nested数据类型场景_第9张图片

129、商城业务-商品上架-nested数据类型场景_第10张图片

129、商城业务-商品上架-nested数据类型场景_第11张图片

这样就处理里数据扁平化处理的错误

129、商城业务-商品上架-nested数据类型场景_第12张图片

 

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(谷粒商城)