elasticsearch 添加settings and mapping

http://blog.youkuaiyun.com/dm_vincent/article/details/46996021

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html

https://elasticsearch.cn/question/2158

一。没有index数据时候方法:
1.后台创建空的index
2.配置analysis
执行以下:
特别注意:analysis中引用test,例如: userdict_ja.txt 如果太大,后边是没办法open的。

curl -XPOST 'localhost:9220/lbsindex/_close?pretty'
curl -XPUT 'localhost:9220/lbsindex/_settings?pretty' -H 'Content-Type: application/json' -d'
{"analysis":{
"filter":{
"stopword_dict":{
"type": "stop",
"stopwords_path": "stopword.txt"
},
"stopword_dict2":{
"type": "stop",
"stopwords": "_english_"
},
"katakana_stemmer":{
"type": "kuromoji_stemmer",
"minimum_length": 4
},
"whitespace_remove": {
"type": "pattern_replace",
"pattern": " ",
"replacement": ""
},
"filter_length": {
"type": "length",
"min": 1
}
},
"tokenizer":{
"kuromoji_user_dict": {
"type": "kuromoji_tokenizer",
"mode": "search",
"discard_punctuation": "false",
"user_dictionary": "userdict_ja.txt"
}
},
"analyzer":{
"myanalyzer":{
"type": "custom",
"tokenizer": "kuromoji_user_dict",
"filter": ["kuromoji_baseform","lowercase","stopword_dict","stopword_dict2","katakana_stemmer","cjk_width","whitespace_remove","filter_length"]
}
}
}
}'
curl -XPOST 'localhost:9220/lbsindex/_open?pretty'
#强制open:curl -i -XPOST 'http://localhost:9200/megacorp/_open/?pretty'

3.后台put_mapping


二。存在index数据的情况下:

https://www.elastic.co/blog/changing-mapping-with-zero-downtime


常用操作:

查看setings:

curl -XGET "localhost:9220/lbsindex/_settings?pretty"

查看mapping

curl -XGET "localhost:9220/lbsindex/item/_mapping?pretty"

添加mappings:
curl -XPUT localhost:9220/lbsindex/_mapping/item -H 'Content-Type: application/json' -d'
{
"mappings":{
"item" : {
"properties" : {
"geo": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
}
}
}'

添加字段:
curl -XPUT 'http://localhost:9220/test-index/_mapping/logs_june' -d '
{
"logs_june" : {
"properties" : {
"message" : {"type" : "string", "store" : true }
}
}
}
'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值