1.安装pinyin插件和ik插件。
2.先创建type(kibana操作):
PUT article_v2018051101/
{
"index": {
"analysis": {
"analyzer": {
"ik_pinyin_analyzer": {
"type": "custom",
"tokenizer": "ik_smart",
"filter": [
"my_pinyin",
"word_delimiter"
]
}
},
"filter": {
"my_pinyin": {
"lowercase": "true",
"type": "pinyin",
"limit_first_letter_length": "16",
"keep_original": "true",
"keep_full_pinyin": "true",
"keep_none_chinese ":"true",
"keep_first_letter":"true",
"keep_none_chinese_together":"true",
"none_chinese_pinyin_tokenize":"true",
"keep_original ":"true"
}
}
}
}
}
3.创建mapping(article_category_index字段添加了ik和pinyin分词):
POST /article_v5251571/info/_mapping
{
"info": {
"properties": {
"article_activity": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"article_activity_type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"article_add_time": {
"type": "date"
},
"article_brand_first_char": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"article_brand_id": {
"type": "long"
},
"article_brand_logo": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"article_brand_name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"article_category_id": {
"type": "long"
},
"article_category_index": {
"type": "text",
"fields": {
"pinyin": {
"type": "text",
"store": "no",
"term_vector": "with_positions_offsets",
"analyzer": "ik_pinyin_analyzer"
}
}
},
"article_category_name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"article_distribution_area": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"article_freeshipping_area": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"article_goods_expenses": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"article_goods_no": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"article_id": {
"type": "long"
},
"article_img_url": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"article_market_price": {
"type": "float"
},
"article_old_sell_price": {
"type": "float"
},
"article_order_times": {
"type": "long"
},
"article_purchase_commodity_price": {
"type": "long"
},
"article_review_score": {
"type": "long"
},
"article_sell_price": {
"type": "float"
},
"article_special_app_price": {
"type": "long"
},
"article_sub_title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"article_tags": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"article_title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"article_user_category_id": {
"type": "long"
},
"article_user_category_name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"case_article_activity_type": {
"type": "long"
},
"class_list": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"class_list_name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"fav_times": {
"type": "long"
},
"gift_rule": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"id": {
"type": "long"
},
"is_activity": {
"type": "long"
},
"is_free": {
"type": "long"
},
"left_shop_send_area": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"pc_logo": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"pics": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"scope_values": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"score": {
"type": "long"
},
"shop_brand": {
"type": "long"
},
"shop_id": {
"type": "long"
},
"shop_name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"shop_order_times": {
"type": "long"
},
"shop_review_score": {
"type": "long"
},
"shop_send_area": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"thumb_path_arr": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"update_time": {
"type": "date"
},
"vote_times": {
"type": "long"
},
"wap_logo": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
4.查看mapping属性:
get article_v5251571/_mapping