我在 EC2 单服务器设置上使用 Rails、Tire 和 Elasticsearch,没有分片或复制(这是 Jenkins CI 服务器)。使用这样的自定义初始化程序:
analysis:
filter:
name_synonyms:
type: synonym
synonyms_path: <%= Rails.root.join("config", "synonyms", "name_synonyms.txt") %>
该文件通过 Erubis 运行,同义词路径转换为如下内容:
/root/workspace/project-project-0f317744a1870b4baf61bbaeb390ebe1/config/synonyms/term_synonyms.txt
当我列出服务器中的文件时,我看到以下内容:
root@ip-XX-XXX-XX-XXX:~/workspace/project-project-0f317744a1870b4baf61bbaeb390ebe1/config/synonyms# ls -la
total 20
drwxr-xr-x 2 root root 4096 Feb 11 18:25 .
drwxr-xr-x 7 root root 4096 Feb 11 18:25 ..
-rw-r--r-- 1 root root 3117 Feb 11 18:25 location_synonyms.txt
-rw-r--r-- 1 root root 3999 Feb 11 18:25 name_synonyms.txt
-rw-r--r-- 1 root root 2144 Feb 11 18:25 term_synonyms.txt
这正是我所期待的,但是我在运行时看到以下错误rake spec
500 : {"error":"IndexCreationException[[test_facilities] failed to create index]; nested: FailedToResolveConfigException[Failed to resolve config path [/root/workspace/project-project-0f317744a1870b4baf61bbaeb390ebe1/config/synonyms/term_synonyms.txt], tried file path [/root/workspace/project-project-0f317744a1870b4baf61bbaeb390ebe1/config/synonyms/term_synonyms.txt], path file [/etc/elasticsearch/root/workspace/project-project-0f317744a1870b4baf61bbaeb390ebe1/config/synonyms/term_synonyms.txt], and classpath]; ","status":500}
在我看来,虽然路径正确,但 Elasticsearch 无法加载文件,可能是加载顺序问题,我真的不太确定。