我正在使用以下docker-compose.yml创建一个ElasticSearch集群:
version: '3.3'
services:
elasticsearch1:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
container_name: elasticsearch1
environment:
...
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data01:/usr/share/elasticsearch/data
- ${PWD}/data/thesaurus/output:/usr/share/elasticsearch/config/extra
ports:
- 9200:9200
networks:
- elastic
elasticsearch2:
...
volumes:
data01:
driver: local
data02:
driver: local
networks:
elastic:
driver: bridge
我的索引包含:
"settings": {
"number_of_shards": 2,
"number_of_replicas": 1,
"index" : {
"analysis" : {
"filter" : {
"synonym" : {
"type" : "synonym",
"synonyms_path" : "extra/synonym.txt"
}
},
"analyzer" : {
"synonym" : {
"tokenizer" : "standard",
"filter" : ["lowercase", "synonym"]
}
}
}
}
当我尝试对数据进行
PUT
时,我得到:{'error': {'root_cause': [{'type': 'illegal_argument_exception', 'reason': 'failed to build synonyms'}], 'type': 'illegal_argument_exception', 'reason': 'failed to build synonyms', 'caused_by': {'type': 'i_o_exception', 'reason': 'Is a directory'}}, 'status': 400}
有趣的是,当我运行
docker exec elasticsearch1 cat config/extra/synonym.txt
时,出现错误:cat: config/extra/synonym.txt: Is a directory
如何加载和使用synonym.txt文件?
最佳答案
如 flex 文档中所写-here:
因此,您替换了synonyms_path
:
"synonyms_path" : "/extra/synonym.txt"
在:
"synonyms_path" : "extra/synonym.txt"