elasticsearch5.6.1 在线安装ik,pinyin插件

必须安装指定版本的插件,不然会报错

安装ik

ik github地址

[admin@k8s-harbor elasticsearch-5.6.1]$ ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.6.1/elasticsearch-analysis-ik-5.6.1.zip
-> Downloading https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.6.1/elasticsearch-analysis-ik-5.6.1.zip
[=================================================] 100%   
-> Installed analysis-ik

安装pinyin

pinyin github地址

wget https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v5.6.1/elasticsearch-analysis-pinyin-5.6.1.zip

elasticsearch5.6.1 在线安装ik,pinyin插件_第1张图片
下载后解压
elasticsearch5.6.1 在线安装ik,pinyin插件_第2张图片
elasticsearch5.6.1 在线安装ik,pinyin插件_第3张图片

重启所有es节点

ps aux|grep elasticsearch |grep -v grep | cut -c 9-15 | xargs kill

./bin/elasticsearch -d

通过kibana创建索引

{
	"settings": {
		"index": {
			"number_of_shards": "5",
			"analysis": {
				"filter": {
					"my_stopwords": {
						"type": "stop",
						"stopwords_path": "stopwords.txt"
					}
				},
				"analyzer": {
					"pinyin_first_letter": {
						"type": "custom",
						"tokenizer": "pinyin_first_letter"
					},
					"smart_analyzer": {
						"type": "custom",
						"char_filter": ["html_strip"],
						"tokenizer": "ik_smart"
					},
					"my_analyzer": {
						"type": "custom",
						"char_filter": ["html_strip"],
						"tokenizer": "ik_max_word"
					},
					"pinyin_analyzer": {
						"type": "custom",
						"tokenizer": "my_pinyin"
					}
				},
				"tokenizer": {
					"pinyin_first_letter": {
						"lowercase": "true",
						"keep_original": "false",
						"keep_first_letter": "true",
						"keep_separate_first_letter": "false",
						"type": "pinyin",
						"limit_first_letter_length": "50",
						"keep_full_pinyin": "false"
					},
					"my_pinyin": {
						"lowercase": "true",
						"keep_original": "false",
						"remove_duplicated_term": "false",
						"keep_separate_first_letter": "false",
						"type": "pinyin",
						"limit_first_letter_length": "16",
						"keep_full_pinyin": "true"
					}
				}
			},
			"number_of_replicas": "1"
		}
	},
	"mappings": {
		"department": {
			"properties": {
				"innerId": {
					"type": "keyword"
				},
				"name": {
					"analyzer": "my_analyzer",
                    "type": "text",
					"fields": {
						"pinyin_first_letter": {
							"analyzer": "pinyin_first_letter",
							"type": "text"
						},
						"ik": {
							"analyzer": "my_analyzer",
							"type": "text"
						},
						"pinyin": {
							"analyzer": "pinyin_analyzer",
							"type": "text"
						},
						"text": {
							"type": "keyword"
						}
					}
				},
				"topCourtId": {
					"type": "keyword"
				},
				"id": {
					"type": "keyword"
				},
				"isActive": {
					"type": "boolean"
				},
				"type": {
					"type": "integer"
				},
				"courtId": {
					"type": "keyword"
				}
			}
		}
	}
}

elasticsearch5.6.1 在线安装ik,pinyin插件_第4张图片

你可能感兴趣的:(elasticsearch)