【发布时间】:2021-01-17 12:45:36
【问题描述】:
我正在从 docker-compose.yml 文件运行 elasticsearch:
version: '3'
services:
mongo:
image: mongo
container_name: mongo-cust-mycom
ports:
- 27017:27017
volumes:
- cust-mycom-mongo:/data/db
networks:
- cust-mycom
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.5.4
container_name: elasticsearch-cust-mycom
ports:
- 9200:9200
- 9300:9300
volumes:
- cust-mycom-elastic:/usr/share/elasticsearch/data
- ./cust/config/elasticsearch/config/hunspell:/usr/share/elasticsearch/config/hunspell
networks:
- cust-mycom
environment:
- cluster.name=i3-elasticsearch
- xpack.security.enabled=false
- xpack.monitoring.enabled=false
- xpack.ml.enabled=false
- xpack.graph.enabled=false
- xpack.watcher.enabled=false
restart: unless-stopped
kibana:
image: docker.elastic.co/kibana/kibana:6.5.4
container_name: kibana-cust-mycom
ports:
- 5601:5601
networks:
- cust-mycom
depends_on:
- elasticsearch
restart: unless-stopped
networks:
cust-mycom:
driver: bridge
volumes:
cust-mycom-mongo:
cust-mycom-elastic:
使用docker-compose up -d。
当我尝试使用以下 json 创建所需的索引时:
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 2,
"analysis": {
"filter": {
"swedish_stemmer": {
"type": "hunspell",
"language": "sv_SE"
},
"ins_pattern": {
"type": "pattern_capture",
"patterns": [
"([a-zåäö]*)(prod)"
]
},
"cust_stopwords": {
"type": "stop",
"stopwords": [ "en", "ett", "det", "den" ]
}
},
"analyzer": {
"swedish_index": {
"tokenizer": "standard",
"filter": [
"lowercase",
"ins_pattern",
"swedish_stemmer"
]
},
"swedish_query": {
"tokenizer": "standard",
"filter": [
"lowercase",
"swedish_stemmer",
"cust_stopwords"
]
}
}
}
},
"mappings": {
"default": {
"properties": {
"keywords": {
"type": "text",
"store": true,
"norms": false,
"analyzer": "swedish_index",
"search_analyzer": "swedish_query"
},
"audience": {
"type": "keyword"
},
"contentExcerpt": {
"type": "text"
},
"date": {
"type": "date",
"store": true,
"format": "dateOptionalTime"
},
"validUntil": {
"type": "date",
"store": true,
"format": "dateOptionalTime"
},
"informationType": {
"type": "text",
"store": true,
"norms": false,
"analyzer": "swedish_index",
"search_analyzer": "swedish_query"
},
"mainContentOfPage": {
"type": "text",
"store": true,
"norms": false,
"analyzer": "swedish_index",
"search_analyzer": "swedish_query",
"term_vector": "with_positions_offsets"
},
"thumbnailUrl": {
"type": "keyword",
"store": true,
"norms": false
},
"title": {
"type": "text",
"store": true,
"norms": false,
"analyzer": "swedish_index",
"search_analyzer": "swedish_query"
},
"url": {
"type": "keyword",
"store": true,
"norms": false
},
"tags": {
"type": "text",
"store": true,
"norms": false,
"analyzer": "swedish_index",
"search_analyzer": "swedish_query"
}
}
}
}
}
以及以下脚本:
#!/bin/bash
curl -XDELETE http://localhost:9200/main
curl -XPUT -H "Content-type: application/json" -d @json/custse.index.json http://localhost:9200/main
curl -XPUT http://localhost:9200/main/_settings -H "Content-Type: application/json" -d "{
\"index\" : {
\"number_of_replicas\" : 0
}
}"
我收到以下错误消息:
{"error":{"root_cause":[{"type":"illegal_state_exception","reason":"failed to load hunspell dictionary for locale: sv_SE"}]
我尝试将我的 hunspell 词典放入 /usr/share/elasticsearch/config/hunspell/、/usr/share/elasticsearch/hunspell、/etc/elasticsearch/hunspell 和 /etc/elasticsearch/config/hunspell。它找不到任何一个。
这里是 hunspell 文件的内容:
/etc/elasticsearch$ ls hunspell
sv_SE
/etc/elasticsearch$ ls hunspell/sv_SE/
cust.dic README_sv_SE.txt sv_SE.aff sv_SE.dic
如何让 elasticsearch 找到 hunspell 字典?
【问题讨论】:
-
创建了一个 /etc/sysconfig 文件夹并将 hunspell 放在那里,没有变化。
-
发现我在 docker-compose.yml 中的本地路径指向了错误的地方。
-
@Sahand 如果您已解决问题,请添加您自己的答案
标签: docker elasticsearch hunspell