0
点赞
收藏
分享

微信扫一扫

ElasticSearch常用语句


数据查询

GET mall_product/_search
{
"query": {
"match_all": {}

},
"aggs": {
"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": {
"catelog_name_agg": {
"terms": {
"field": "catalogName",
"size": 10
}
},
"sale_agg": {
"terms": {
"field": "saleCount",
"size": 10
}
}
}
},
"attr_agg":{
"nested": {
"path": "attrs"
},
"aggs": {
"attr_id_agg": {
"terms": {
"field": "attrs.attrId",
"size": 10
},
"aggs": {
"name_agg": {
"terms": {
"field": "attrs.attrName",
"size": 10
}
},
"value_agg":{
"terms": {
"field": "attrs.attrValue",
"size": 10
}
}
}
}
}
}
}
}

创建索引

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

迁移数据

POST _reindex
{
"source": {"index": "gulimall_product"},
"dest": {"index": "mall_product"}
}

删除索引

DELETE mall_product

查看索引

GET mall_product/_mapping


举报

相关推荐

SQL常用语句

sqlite常用语句

python常用语句

MYSQL常用语句

PostGIS常用语句备忘

0 条评论