1.创建mapping
put:http://127.0.0.1:9200/match/_bulk
{ "mappings": { "doc": { "properties": { "productName": { "type": "text", "analyzer": "ik_smart" } } } } }
ik分词有2种分词类型ik_max_word ik_smart 细粒度分词和粗粒度分词 自行百度
2.添加测试数据
{"create":{"_index":"match","_type":"doc","_id":1}} {"productName":"雪花纯爽8度500ml绿瓶1*12纸箱绿版"} {"create":{"_index":"match","_type":"doc","_id":2}} {"productName":"雪花纯爽8度150ml绿瓶1*13纸箱绿版"} {"create":{"_index":"match","_type":"doc","_id":3}} {"productName":"勇闯天涯8度150ml绿瓶1*13纸箱绿版"} {"create":{"_index":"match","_type":"doc","_id":4}} {"productName":"勇闯天涯8度300ml绿瓶1*13纸箱绿版"}