NutzSite

Java快速开发框架


elasticsearch8.14.3 加分词

<p>elasticsearch8.14.3 加分词 目录</p> <pre><code>├── Dockerfile ├── config │   ├── analysis-ik │   │   └── IKAnalyzer.cfg.xml │   └── synonym.dic ├── data └── docker-compose.yml</code></pre> <p>DockerFile 主要分词下载工具地址 <code>https://release.infinilabs.com/analysis-pinyin/stable/</code></p> <pre><code>FROM docker.elastic.co/elasticsearch/elasticsearch:8.14.3 # 安装 IK 分词器 (官方推荐方式) RUN bin/elasticsearch-plugin install --batch \ https://get.infini.cloud/elasticsearch/analysis-ik/8.14.3 # 安装 Pinyin 分词器 RUN bin/elasticsearch-plugin install --batch \ https://release.infinilabs.com/analysis-pinyin/stable/elasticsearch-analysis-pinyin-8.14.3.zip # 创建配置目录 RUN mkdir -p /usr/share/elasticsearch/config/analysis-ik # 复制配置文件 COPY ./config/synonym.dic /usr/share/elasticsearch/config/ COPY ./config/analysis-ik/ /usr/share/elasticsearch/config/analysis-ik/</code></pre> <p>docker-compose.yml</p> <pre><code>version: &amp;quot;3.8&amp;quot; services: elasticsearch: build: . container_name: elasticsearch-8.14.3 environment: - discovery.type=single-node - ES_JAVA_OPTS=-Xms2g -Xmx2g - ELASTIC_PASSWORD=youpassword - xpack.security.enabled=true ulimits: memlock: soft: -1 hard: -1 ports: - &amp;quot;9200:9200&amp;quot; - &amp;quot;9300:9300&amp;quot; volumes: - ./data:/usr/share/elasticsearch/data networks: - es_net healthcheck: test: [ &amp;quot;CMD-SHELL&amp;quot;, &amp;quot;curl --silent --fail -u elastic:yourpassword http://localhost:9200/_cluster/health || exit 1&amp;quot;, ] interval: 30s timeout: 10s retries: 3 networks: es_net: driver: bridge volumes: data: driver: local </code></pre> <p>vim config/analysis-ik/IKAnalyzer.cfg.xml</p> <pre><code>&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt; &amp;lt;!DOCTYPE properties SYSTEM &amp;quot;http://java.sun.com/dtd/properties.dtd&amp;quot;&amp;gt; &amp;lt;properties&amp;gt; &amp;lt;comment&amp;gt;IK Analyzer 扩展配置&amp;lt;/comment&amp;gt; &amp;lt;entry key=&amp;quot;ext_dict&amp;quot;&amp;gt;&amp;lt;/entry&amp;gt; &amp;lt;entry key=&amp;quot;ext_stopwords&amp;quot;&amp;gt;&amp;lt;/entry&amp;gt; &amp;lt;entry key=&amp;quot;remote_ext_dict&amp;quot;&amp;gt;&amp;lt;/entry&amp;gt; &amp;lt;entry key=&amp;quot;remote_ext_stopwords&amp;quot;&amp;gt;&amp;lt;/entry&amp;gt; &amp;lt;entry key=&amp;quot;synonyms_path&amp;quot;&amp;gt;synonym.dic&amp;lt;/entry&amp;gt; &amp;lt;/properties&amp;gt;</code></pre> <p>vim config/synonym.dic</p> <pre><code>北京, 北京市, 北平 中国, 中华人民共和国</code></pre>

页面列表

ITEM_HTML