一般一个index在每个节点有一个shard,每个shard有一个副本
PUT /career_plan_sku_index_15{"settings": {// 几个分片"number_of_shards": 3,// 每个分片有多少个副本"number_of_replicas": 1},"mappings": {"properties": {"skuId": {"type": "keyword"},"skuName": {"type": "text","analyzer": "ik_max_word","search_analyzer": "ik_smart"},"category": {"type": "keyword"},"basePrice": {"type": "integer"},"vipPrice": {"type": "integer"},"saleCount": {"type": "integer"},"commentCount": {"type": "integer"},"skuImgUrl": {"type": "keyword","index": false},"createTime": {"type": "date","format": "yyyy-MM-dd HH:mm:ss"},"updateTime": {"type": "date","format": "yyyy-MM-dd HH:mm:ss"}}}}
ik_max_word
会尽可能把一个次拆分成多的各种分词组合。
比如中华人民共和国,会拆成:中华、华人、人民、中华人民、人民共和国、共和国、中华人民共和国
ik_smart
拆的粒度比较粗。
比如中华人民共和国,会拆成:中华、人民、共和国
一般我们在写入数据的时候使用 ik_max_word,建立非常精细的各种小词。对字段搜索时,一般使用 ik_smart,这样搜索的结果更加匹配。
suggest 建模
PUT /career_plan_sku_suggest_15{"settings": {"number_of_shards": 3,"number_of_replicas": 1,"analysis": {"analyzer": {"ik_and_pinyin_analyzer": {"type": "custom","tokenizer": "ik_smart","filter": "my_pinyin"}},"filter": {"my_pinyin": {"type": "pinyin","keep_first_letter": true,"keep_full_pinyin": true,"keep_original": true,"remove_duplicated_term": true}}}},"mappings": {"properties": {"word1": {"type": "completion","analyzer": "ik_and_pinyin_analyzer"},"word2": {"type": "text"}}}}
