我正在使用下面的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文件?
发布于 2020-04-15 13:40:39
原来这是WSL的一个问题-参见: github.com/docker/for-win/issues/2151
作为解决办法,我将我的synonym.txt放在一个Windows目录中,然后链接到它,如下所示:
volumes:
- data01:/usr/share/elasticsearch/data
- /c/QAMaker:/usr/share/elasticsearch/config/extra注:我的Windows文件系统安装在/c上的Docker和WSL发行版上。我不确定如果在我的发行版中将Windows文件系统挂载在默认的/mnt/c上,这是否有效
发布于 2020-04-15 12:00:01
如弹性文档所写- 这里
上面配置了一个同义词过滤器,其中包含一个分析路径/同义词. to (相对于配置位置)。然后用过滤器配置同义词分析器。
因此,您可以替换synonyms_path:
"synonyms_path" : "/extra/synonym.txt" 在:
"synonyms_path" : "extra/synonym.txt"https://stackoverflow.com/questions/61227043
复制相似问题