一、报错内容
报错:"reason":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text
fields by default. Set fielddata=true on [brandName] in order to load fielddata in memory
by uninverting the inverted index. Note that this can however use significant memory.
二、报错原因
在P178中数据迁移product迁移到gulimall_product一定要迁移!我漏做了
三、解决方法
创建一个新的索引gulimall_product
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"
},
"catalogId": {
"type": "long"
},
"catalogName": {
"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"
}
}
}
}
数据迁移
POST _reindex
{
"source": {
"index": "product"
}
, "dest": {
"index": "gulimall_product"
}
}
我这里就可以显示search的信息了
做了这两步就不会报ES错误,如果还会 可以试试在MallSearchServiceImpl文件中所有聚合分析的子聚合加**.keyword**
brand_agg.subAggregation(AggregationBuilders.terms("brand_name_agg").field("brandName.keyword").size(1));