--- title: "不能同时设置mode和enabled参数 – 如何解决此Elasticsearch异常" date: 2026-02-24 lastmod: 2026-02-24 description: "在Elasticsearch中尝试同时设置mode和enabled参数时会报错,这两个参数互斥,只能使用其中一个。解决方法是检查配置并移除其中一个参数,然后重启Elasticsearch。" tags: ["Elasticsearch", "参数设置", "配置冲突", "模式参数", "映射解析"] summary: " 版本: 8.4-8.9 简要来说,当您尝试在Elasticsearch设置中同时设置[mode]和[enabled]参数时,就会出现此错误。这两个参数是互斥的,意味着您一次只能使用其中一个。要解决此问题,您应该在设置中只使用[mode]或[enabled]参数中的一个,而不能同时使用两者。请检查您的配置,删除或注释掉其中一个参数。然后,重启Elasticsearch以应用更改。 日志上下文 # 日志"Cannot set both [mode] and [enabled] parameters"的类名是 SourceFieldMapper.java。 我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入上下文的人参考: public SourceFieldMapper build() { if (enabled.getValue().explicit() && mode.get() != null) { if (indexMode == IndexMode.TIME_SERIES) { throw new MapperParsingException("Time series indices only support synthetic source"); } else { throw new MapperParsingException("Cannot set both [mode] and [enabled] parameters"); } } if (isDefault()) { return indexMode == IndexMode.TIME_SERIES ? TSDB_DEFAULT : DEFAULT; } " --- > **版本:** 8.4-8.9 简要来说,当您尝试在Elasticsearch设置中同时设置[mode]和[enabled]参数时,就会出现此错误。这两个参数是互斥的,意味着您一次只能使用其中一个。要解决此问题,您应该在设置中只使用[mode]或[enabled]参数中的一个,而不能同时使用两者。请检查您的配置,删除或注释掉其中一个参数。然后,重启Elasticsearch以应用更改。 日志上下文 ----------- 日志"Cannot set both [mode] and [enabled] parameters"的类名是[SourceFieldMapper.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入上下文的人参考: ```java public SourceFieldMapper build() { if (enabled.getValue().explicit() && mode.get() != null) { if (indexMode == IndexMode.TIME_SERIES) { throw new MapperParsingException("Time series indices only support synthetic source"); } else { throw new MapperParsingException("Cannot set both [mode] and [enabled] parameters"); } } if (isDefault()) { return indexMode == IndexMode.TIME_SERIES ? TSDB_DEFAULT : DEFAULT; } ```