本文共 1948 字,大约阅读时间需要 6 分钟。
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 } } } } '