elasticsearch安装ik分词器

elasticsearch安装ik分词器

1. 修改docker-compose.yml文件,对es目录下的plugins文件夹进行文件映射

version: "2.2"
volumes:
  data:
  config:
networks:
  es:
services:
  elasticsearch:
    image: elasticsearch:7.6.0
    ports:
      - "9200:9200"
      - "9300:9300"
    networks:
      - "es"
    environment:
      - "discovery.type=single-node"
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    volumes:
      - data:/usr/share/elasticsearch/data
      - config:/usr/share/elasticsearch/config
      - /elk/es-kibana-compose/ik-7.6.0:/usr/share/elasticsearch/plugins/ik-7.6.0
  kibana:
    image: kibana:7.6.0
    ports:
      - "5601:5601"
    networks:
      - "es"
    volumes:
      - /elk/es-kibana-compose/kibana.yml:/usr/share/kibana/config/kibana.yml

2. 下载安装ik分词器

2.1 下载ik

  • 方式一:直接下载
# 现在ik分词器,这里要注意的是ik分词器的版本要与es版本保持一致
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.6.0/elasticsearch-analysis-ik-7.6.0.zip
  • 方式二:去github下载,下面是下载地址,选择相应的版本与es版本保持一致
https://github.com/medcl/elasticsearch-analysis-ik/releases/

2.2 安装ik

# 移动到指定挂载目录
mv elasticsearch-analysis-ik-7.6.0.zip /elk/es-kibana-compose/ik-7.6.0
# 解压
unzip ik-7.6.0.zip
rm -rf ik-7.6.0.zip

3. 测试

POST _analyze
{
  "analyzer": "ik_max_word",
  "text": "我爱你的我的祖国"
}

POST _analyze
{
  "analyzer": "ik_smart",
  "text": "我爱你的我的祖国"
}

你可能感兴趣的:(elasticsearch,elasticsearch,大数据,big,data)