elasticsearch 添加settings and mapping
程序员文章站
2022-07-12 16:39:04
...
http://blog.csdn.net/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 }
}
}
}
'
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 }
}
}
}
'
推荐阅读
-
ElasticStack学习(七):ElasticSearch之Mapping初探
-
ES 11 - 配置Elasticsearch的映射(mapping)
-
Elasticsearch-2.4.x > Mapping > Meta-fields > _all
-
Elasticsearch-2.4.x > Mapping > Meta-fields > _field_names
-
Elasticsearch、Logstash、Kibana手把手教你添加密码设置
-
elasticsearch 添加settings and mapping
-
elasticsearch 添加settings and mapping
-
区分ElasticSearch中的Mapping和Type luceneelasticsearchmappingtypedifference
-
Elasticsearch: 理解mapping中的store属性
-
Elasticsearch 7.x 映射(Mapping)中的字段类型