GET alatusmall_product/_search?size=100 { "query": { "match_all": {} }, "aggs": { "brand_agg" : { "terms": { "field": "brandId", "size": 10 }, "aggs": { "brand_name_agg": { "terms": { "field": "brandName", "size": 10 } } } }, "catelog_agg" : { "terms": { "field": "catalogId", "size": 10 } } }, "sort": [ { "skuPrice": { "order": "desc" } } ] } GET alatusmall_product/_search?size=1000 POST _reindex { "source": { "index": "product" }, "dest": { "index": "alatusmall_product" } } PUT alatusmall_product { "mappings": { "properties": { "skuId": { "type": "long" }, "spuId": { "type": "keyword" }, "skuTitle": { "type": "text", "analyzer": "ik_smart" }, "skuPrice": { "type": "keyword" }, "skuImg": { "type": "keyword" }, "saleCount": { "type": "long" }, "hasStock": { "type": "boolean" }, "hotScore": { "type": "long" }, "brandId": { "type": "long" }, "catalogId": { "type": "long" }, "brandName": { "type": "keyword" }, "brandImg": { "type": "keyword" }, "catalogName": { "type": "keyword" }, "attrs": { "type": "nested", "properties": { "attrId": { "type": "long" }, "attrName": { "type": "keyword" }, "attrValue": { "type": "keyword" } } } } } }
GET alatusmall_product/_search?size=100
{
"query": {
"match_all": {}
},
"aggs": {
"brand_agg" : {
"terms": {
"field": "brandId",
"size": 10
},
"aggs": {
"brand_name_agg": {
"terms": {
"field": "brandName",
"size": 10
}
}
}
},
"catelog_agg" : {
"terms": {
"field": "catalogId",
"size": 10
}
}
},
"sort": [
{
"skuPrice": {
"order": "desc"
}
}
]
}GET alatusmall_product/_search?size=1000
POST _reindex
{
"source": {
"index": "product"
},
"dest": {
"index": "alatusmall_product"
}
}PUT alatusmall_product
{
"mappings": {
"properties": {
"skuId": {
"type": "long"
},
"spuId": {
"type": "keyword"
},
"skuTitle": {
"type": "text",
"analyzer": "ik_smart"
},
"skuPrice": {
"type": "keyword"
},
"skuImg": {
"type": "keyword"
},
"saleCount": {
"type": "long"
},
"hasStock": {
"type": "boolean"
},
"hotScore": {
"type": "long"
},
"brandId": {
"type": "long"
},
"catalogId": {
"type": "long"
},
"brandName": {
"type": "keyword"
},
"brandImg": {
"type": "keyword"
},
"catalogName": {
"type": "keyword"
},
"attrs": {
"type": "nested",
"properties": {
"attrId": {
"type": "long"
},
"attrName": {
"type": "keyword"
},
"attrValue": {
"type": "keyword"
}
}
}
}
}
}
package com.alatus.search.constant; public class EsConstant { public static final String PRODUCT_INDEX = "alatusmall_product"; }
package com.alatus.search.constant; public class EsConstant { public static final String PRODUCT_INDEX = "alatusmall_product"; }
GET alatusmall_product/_search?size=100 { "query": { "term": { "brandId": { "value": "1" } } }, "aggs": { "attr_agg": { "nested": { "path": "attrs" }, "aggs": { "attr_id": { "terms": { "field": "attrs.attrId", "size": 10 }, "aggs": { "attr_name": { "terms": { "field": "attrs.attrName", "size": 10 } }, "attr_value" : { "terms": { "field": "attrs.attrValue", "size": 10 } } } } } }, "brand_agg": { "terms": { "field": "brandId", "size": 10 }, "aggs": { "brand_name_agg": { "terms": { "field": "brandName", "size": 10 } }, "brand_img_agg": { "terms": { "field": "brandImg", "size": 10 } } } }, "catelog_agg": { "terms": { "field": "catalogId", "size": 10 }, "aggs": { "catalog_name_agg": { "terms": { "field": "catalogName", "size": 10 } } } } }, "sort": [ { "skuPrice": { "order": "desc" } } ] }
GET alatusmall_product/_search?size=100
{
"query": {
"term": {
"brandId": {
"value": "1"
}
}
},
"aggs": {
"attr_agg": {
"nested": {
"path": "attrs"
},
"aggs": {
"attr_id": {
"terms": {
"field": "attrs.attrId",
"size": 10
},
"aggs": {
"attr_name": {
"terms": {
"field": "attrs.attrName",
"size": 10
}
},
"attr_value" : {
"terms": {
"field": "attrs.attrValue",
"size": 10
}
}
}
}
}
},
"brand_agg": {
"terms": {
"field": "brandId",
"size": 10
},
"aggs": {
"brand_name_agg": {
"terms": {
"field": "brandName",
"size": 10
}
},
"brand_img_agg": {
"terms": {
"field": "brandImg",
"size": 10
}
}
}
},
"catelog_agg": {
"terms": {
"field": "catalogId",
"size": 10
},
"aggs": {
"catalog_name_agg": {
"terms": {
"field": "catalogName",
"size": 10
}
}
}
}
},
"sort": [
{
"skuPrice": {
"order": "desc"
}
}
]
}