elasticsearch添加索引

本文详细介绍了如何在Elasticsearch中创建索引并设置mapping,包括设置刷新间隔、字段限制、分片数量等参数,以及使用jieba分词器进行中文分析,配置了多种类型字段如日期、整数、关键字和文本字段,并定义了嵌套字段和动态模板。

--创建索引
PUT http://127.0.0.1:9200/spark_index_sl_1
head Content-Type:application/json;charset=utf-8

--设置mapping大小
PUT http://127.0.0.1:9200/spark_index_sl_1
head Content-Type:application/json;charset=utf-8
body

{
"settings": {
"refresh_interval":"600s",
"index.mapping.total_fields.limit": 200000,
"number_of_shards" : 16,
"number_of_replicas": 1,
"analysis": {
"filter": {
"jieba_stop": {
"type": "stop",
"stopwords_path": "plugins/jieba/dic/stopwords.txt"
},
"jieba_synonym": {
"type": "synonym",
"synonyms_path": "plugins/jieba/dic//synonyms.txt"
}
},
"analyzer": {
"sl_index": {
"tokenizer": "jieba_index",
"filter": [
"lowercase",
"jieba_stop",
"jieba_synonym"
]
},
"sl_search": {
"tokenizer": "jieba_search",
"filter": [
"lowercase",
"jieba_stop",
"jieba_synonym"
]
},
"sl_quote": {
"tokenizer": "jieba_index",
"filter": [
"lowercase",
"jieba_synonym"
]
}
}
}
},
"mappings": {
"_doc": {
"dynamic_templates": [{
"project_sentiment_": {
"match": "project_sentiment_*",
"mapping": {
"ignore_above": 10000,
"type": "integer"
}
}
}],

"numeric_detection": true,
"date_detection": false,
"properties": {
"age_seg": {
"type": "integer"
},
"age": {
"type": "integer"
},
"author": {
"type": "keyword"
},
"author_id": {
"type": "keyword"
},
"author_id_md5": {
"type": "keyword"
},
"car_owner": {
"type": "integer"
},
"category_1st": {
"type": "keyword"
},
"category_2nd": {
"type": "keyword"
},
"content": {
"type": "text",
"analyzer":"sl_index",
"search_analyzer":"sl_search",
"search_quote_analyzer":"sl_quote"
},
"content_p": {
"type": "text",
"analyzer":"sl_index",
"search_analyzer":"sl_search",
"search_quote_analyzer":"sl_quote"
},
"ctime": {
"type": "date",
"format": "yyyy-MM-dd"
},
"doc_type": {
"type": "integer"
},
"favourites_count": {
"type": "integer"
},
"floors": {
"type": "integer"
},
"followers_count": {
"type": "integer"
},
"gender": {
"type": "integer"
},
"is_topics": {
"type": "integer"
},
"issue_time": {
"type": "date",
"format": "yyyy-MM-dd"
},
"pgcugc": {
"type": "integer"
},
"pid": {
"type": "keyword",
"ignore_above":10000
},
"sites_type_id": {
"type": "integer"
},
"platform_type_id": {
"type": "integer"
},
"province_id": {
"type": "integer"
},
"sentence": {
"type": "nested",
"properties": {
"attribute_1st": {
"type": "keyword"
},
"attribute_2nd": {
"type": "keyword"
},
"attribute_3rd": {
"type": "keyword"
},
"attribute_4th": {
"type": "keyword"
},
"brand": {
"type": "keyword"
},
"car_series": {
"type": "keyword"
},
"sentiments": {
"type": "integer"
},
"sentiments_word": {
"type": "keyword"
},
"word_cloud": {
"type": "keyword"
}
}
},
"sentiment": {
"type": "integer"
},
"sites_id": {
"type": "integer"
},
"title": {
"type": "text",
"analyzer":"sl_index",
"search_analyzer":"sl_search",
"search_quote_analyzer":"sl_quote"
},
"title_p": {
"type": "text",
"analyzer":"sl_index",
"search_analyzer":"sl_search",
"search_quote_analyzer":"sl_quote"
},
"update_interaction": {
"type": "integer"
},
"update_shares": {
"type": "integer"
},
"update_reposts": {
"type": "integer"
},
"update_dislikes": {
"type": "integer"
},
"update_likes": {
"type": "integer"
},
"update_comments_count": {
"type": "integer"
},
"update_clicks": {
"type": "integer"
},
"update_utility":{
"type":"integer"
},
"all_interaction":{
"type":"integer"
},
"correct_clicks": {
"type": "integer"
},
"correct_comments_count": {
"type": "integer"
},
"correct_likes": {
"type": "integer"
},
"correct_dislikes": {
"type": "integer"
},
"correct_reposts": {
"type": "integer"
},
"correct_shares": {
"type": "integer"
},
"friends_count": {
"type": "integer"
},
"bi_followers_count": {
"type": "integer"
},
"channel_id": {
"type": "integer"
},
"post_id": {
"type": "keyword"
},
"carseries_block": {
"type": "keyword"
},
"car_flag": {
"type": "integer"
},
"province_name": {
"type": "text",
"analyzer":"sl_index",
"search_analyzer":"sl_search",
"search_quote_analyzer":"sl_quote"
},
"month":{
"type":"integer"
},
"avatar_hd":{
"type":"keyword"
},
"p_pid": {
"type": "keyword"
},
"cluster_id": {
"type": "keyword"
},
"cluster_title": {
"type": "keyword"
},
"p_author": {
"type": "keyword"
},
"p_author_id": {
"type": "keyword"
},
"p_author_id_md5": {
"type": "keyword"
},
"id": {
"type": "keyword"
},
"tag": {
"type": "keyword"
},
"project_open": {
"type": "keyword"
},
"project_close": {
"type": "keyword"
},
"cluster_ctime": {
"type": "keyword"
}
}
}
}
}

转载于:https://www.cnblogs.com/flymin/p/11496478.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值