1.es的dsl语句
GET product/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"skuTitle": "华为"
}
}
],
"filter": [
{
"term": {
"catelogId": "225"
}
},
{
"terms": {
"brandId": [
"1",
"2",
"10"
]
}
},
{
"nested": {
"path": "attrs",
"query": {
"bool": {
"must": [
{
"term": {
"attrs.attrId": {
"value": "12"
}
}
},{
"terms": {
"attrs.attrValue": [
"华为Mate X2",
"眼模式;计算器;超大字体;语音命令;SOS功能;语音识别"
]
}
}
]
}
}
}
},
{
"term": {
"hasStock": "true"
}
},
{
"range": {
"skuPrice": {
"gte": 0,
"lte": 18000
}
}
}
]
}
},
"sort": [
{
"skuPrice": {
"order": "desc"
}
}
],
"from": 0,
"size": 1,
"highlight": {
"fields": {"skuTitle": {}},
"pre_tags": "<b style='color:green'>",
"post_tags": "</b>"
}
}
GET product/_search
{
"query": {
"match_all": {}
},
"aggs": {
"brand_agg": {
"terms": {
"field": "brandId",
"size": 10
},
"aggs": {
"brand_name_agg": {
"terms": {
"field": "brandName",
"size": 10
}
}
}
},
"catelog_agg":{
"terms": {
"field": "catelogId",
"size": 10
}
}
}
}
DELETE product
DELETE gulimall_product
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"
},
"catelogId": {
"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"
}
}
}
}
}
}
GET product/_mapping
get gulimall_product/_search
#迁移数据
POST _redindex
{
"source": {
"index": "twitter"
},
"dest": {
"index": "new_twitter"
}
}
PUT gulimall_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"
},
"catelogId": {
"type": "long"
},
"catelogName": {
"type": "keyword"
},
"hasStock": {
"type": "boolean"
},
"hotScore": {
"type": "long"
},
"saleCount": {
"type": "long"
},
"skuId": {
"type": "long"
},
"skuImg": {
"type": "keyword"
},
"skuPrice": {
"type": "keyword"
},
"skuTitle": {
"type": "text",
"analyzer": "ik_smart"
},
"spuId": {
"type": "keyword"
}
}
}
}
GET gulimall_product/_search
GET gulimall_product/_search
##模拟匹配,过滤(按照属性,分类,品牌,价格区间,库存),排序,分页,高亮,聚合分析
{
"query": {
"match_all": {}
},
"aggs": {
"brand_agg": {
"terms": {
"field": "brandId",
"size": 2
},
"aggs": {
"brand_name_agg": {
"terms": {
"field": "brandName",
"size": 2
}
},
"brand_img_agg": {
"terms": {
"field": "brandImg",
"size": 2
}
}
}
},
"catelog_agg": {
"terms": {
"field": "catelogId",
"size": 2
},
"aggs": {
"catelog_name_agg": {
"terms": {
"field": "catelogName",
"size": 2
}
}
}
},
"attr_agg": {
"nested": {
"path": "attrs"
},
"aggs": {
"attr_id_agg": {
"terms": {
"field": "attrs.attrId",
"size": 10
},
"aggs": {
"attr_name_agg": {
"terms": {
"field": "attrs.attrName",
"size": 10
}
},
"attr_value_agg":{
"terms": {
"field": "attrs.attrValue",
"size": 10
}
}
}
}
}
}
}
}
#迁移数据
POST _reindex
{
"source": {
"index": "gulimall_product"
},
"dest": {
"index": "product"
}
}
GET product/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"skuTitle": "华为"
}
}
],
"filter": [
{
"term": {
"catelogId": "225"
}
},
{
"terms": {
"brandId": [
"1",
"2",
"10"
]
}
},
{
"nested": {
"path": "attrs",
"query": {
"bool": {
"must": [
{
"term": {
"attrs.attrId": {
"value": "12"
}
}
},{
"terms": {
"attrs.attrValue": [
"华为Mate X2",
"眼模式;计算器;超大字体;语音命令;SOS功能;语音识别"
]
}
}
]
}
}
}
},
{
"term": {
"hasStock": "true"
}
},
{
"range": {
"skuPrice": {
"gte": 0,
"lte": 18000
}
}
}
]
}
},
"sort": [
{
"skuPrice": {
"order": "desc"
}
}
],
"from": 0,
"size": 1,
"highlight": {
"fields": {"skuTitle": {}},
"pre_tags": "<b style='color:green'>",
"post_tags": "</b>"
}
}
2.查看端口是否被占用
2.1查看某端口是否被占用
netstat -ano | findstr 40003[要查看的端口号]
2.2 查看占用端口对应的进程信息
tasklist | findstr 7888[进程ID]