sku在es中存储结构分析
作者:互联网
有两种存储方式:
方式一
将属性冗余字段一并保存
{
"spuId": xxx,
"skuId": xxx,
"xxxx基本属性": "",
"attrs": {
"属性1"; "xxx",
"属性2": "xxx"
}
}
方式二:
将冗余字段接偶
{
"spuId": xxx,
"skuId": xxx,
"xxxx基本属性": "",
}
{
"spuId": "xx",
"属性1"; "xxx",
"属性2": "xxx"
}
对比两种方式
首先方式一因为将attrs冗余字段一并存储 查询时会比较快 但是浪费了一些空间
其次方式二将sku和attrs接偶 节约了一些空间 但是因为要发送两次请求 所以查询时会比较慢
时间和空间之间的矛盾 我们选择时间 也就是方式一
mapping映射
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"
},
"notScore": {
"type": "long"
},
"brandId": {
"type": "long"
},
"catelogI": {
"type": "long"
},
"brandName": {
"type": "keyword",
"index": false,
"doc_values": false
},
"brandImg": {
"type": "keyword",
"index": false,
"doc_values": false
},
"catelogName": {
"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"
}
}
}
}
}
}
index: 为false
表示不可作为检索条件
标签:sku,index,存储,false,keyword,xxx,long,type,es 来源: https://www.cnblogs.com/lyraHeartstrings/p/15871391.html