--- title: "Hunspell 字典缺少词缀文件 %s - 如何解决此 Elasticsearch 异常" date: 2026-02-19 lastmod: 2026-02-19 description: "Elasticsearch 无法为 Hunspell 字典找到词缀文件时会发生此错误。解决方法是确保字典文件 (.dic) 和词缀文件 (.aff) 都存在于正确的目录中。" tags: ["日志上下文", "Hunspell", "字典", "词缀文件"] summary: "简要来说,当 Elasticsearch 无法为 Hunspell 字典找到词缀文件时,会发生此错误。Hunspell 在 Elasticsearch 中用于文本分析,它需要两个文件:字典文件 (.dic) 和词缀文件 (.aff)。如果其中任何一个文件缺失,就会发生此错误。要解决此问题,请确保两个文件都存在于正确的目录中。如果它们缺失,您可能需要下载它们。此外,请检查 Elasticsearch 配置中的文件路径,确保它们是正确的。 日志上下文 # 日志 “Missing affix file for hunspell dictionary [%s]” 的类名是 HunspellService.java. 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考: boolean ignoreCase = nodeSettings.getAsBoolean("ignore_case"; defaultIgnoreCase); Path[] affixFiles = FileSystemUtils.files(dicDir; "*.aff"); if (affixFiles.length == 0) { throw new ElasticsearchException(String.format(Locale.ROOT; "Missing affix file for hunspell dictionary [%s]"; locale)); } if (affixFiles.length != 1) { throw new ElasticsearchException(String.format(Locale.ROOT; "Too many affix files exist for hunspell dictionary [%s]"; locale)); } InputStream affixStream = null; " --- 简要来说,当 Elasticsearch 无法为 Hunspell 字典找到词缀文件时,会发生此错误。Hunspell 在 Elasticsearch 中用于文本分析,它需要两个文件:字典文件 (.dic) 和词缀文件 (.aff)。如果其中任何一个文件缺失,就会发生此错误。要解决此问题,请确保两个文件都存在于正确的目录中。如果它们缺失,您可能需要下载它们。此外,请检查 Elasticsearch 配置中的文件路径,确保它们是正确的。 日志上下文 ----------- 日志 "Missing affix file for hunspell dictionary [%s]" 的类名是 [HunspellService.java.](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考: ```java boolean ignoreCase = nodeSettings.getAsBoolean("ignore_case"; defaultIgnoreCase); Path[] affixFiles = FileSystemUtils.files(dicDir; "*.aff"); if (affixFiles.length == 0) { throw new ElasticsearchException(String.format(Locale.ROOT; "Missing affix file for hunspell dictionary [%s]"; locale)); } if (affixFiles.length != 1) { throw new ElasticsearchException(String.format(Locale.ROOT; "Too many affix files exist for hunspell dictionary [%s]"; locale)); } InputStream affixStream = null; ```