es创建索引设置字段不分词_elk之es创建索引,添加分词,拼音分词

本文介绍了如何在Elasticsearch中安装pinyin和ik插件,并详细展示了如何创建索引,特别是在`article_category_index`字段上同时应用ik和pinyin分词的设置。通过PUT请求创建了名为`article_v2018051101/`的索引,并定义了自定义的`ik_pinyin_analyzer`,用于全文搜索和拼音搜索。接着,使用POST请求设置了映射(mapping),确保了字段如`article_activity`、`article_category_name`等的正确配置。
摘要由CSDN通过智能技术生成

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值